﻿namespace MDXStudio
{
    using AdvancedDataGridView;
    using MDXParser;
    using MDXStudio.MdSchema;
    using MDXStudio.Properties;
    using MDXStudio.QueryEditor;
    using MDXStudio.Tracing;
    using MDXStudio.Utils;
    using Microsoft.AnalysisServices;
    using Microsoft.AnalysisServices.AdomdClient;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Windows.Forms;
    using WeifenLuo.WinFormsUI.Docking;

    public class MainForm : Form
    {
        private ToolStripMenuItem aboutMDXStudioToolStripMenuItem;
        private MDXStudio.Context AxesContext;
        private ToolStripMenuItem clearCachesToolStripMenuItem;
        private ToolStripMenuItem commentToolStripMenuItem;
        private ToolStripMenuItem communityToolStripMenuItem;
        private IContainer components;
        private ContextMenuStrip contextMenuStripEdit;
        private ToolStripMenuItem coordinatesToolStripMenuItem;
        private ToolStripMenuItem copyContextMenuItem;
        private ToolStripButton copyToolStripButton;
        private ToolStripMenuItem copyToolStripMenuItem;
        private ToolStripMenuItem cutContextMenuItem;
        private ToolStripButton cutToolStripButton;
        private ToolStripMenuItem cutToolStripMenuItem;
        private DataGridView dataGridView1;
        private ToolStripMenuItem debugToolStripMenuItem;
        private ToolStripMenuItem debugToolStripMenuItem1;
        private ToolStripMenuItem debugWatchToolStripMenuItem;
        private ToolStripMenuItem dependenciesToolStripMenuItem;
        private DockPanel dockPanel;
        private ToolStripMenuItem editToolStripMenuItem;
        private ToolStripMenuItem executeQueryToolStripMenuItem;
        private ToolStripMenuItem exitToolStripMenuItem;
        private ToolStripMenuItem feedbackToolStripMenuItem;
        private ToolStripMenuItem fileToolStripMenuItem;
        private ToolStripMenuItem findToolStripMenuItem;
        private ToolStripMenuItem formatExpressionToolStripMenuItem;
        private ToolStripMenuItem formatToolStripMenuItem;
        private ToolStripMenuItem forumToolStripMenuItem;
        private VirtualGrid GridDebugWatch;
        private VirtualGrid GridQueryResults;
        private ToolStripButton helpToolStripButton;
        private ToolStripMenuItem helpToolStripMenuItem;
        private ImageList imageListMetadata;
        private ImageList imageListTabs;
        private ImageList imageListTraceEvents;
        private string[] m_Args;
        private Connection m_Connection;
        private string m_ConnectionString;
        private DebugWatch m_DebugWatch;
        private bool m_fDebugMode;
        private FormatOptions m_formatOptions = new FormatOptions();
        private int m_iQueryWindow;
        private Query m_MdxQuery;
        private MessageLog m_MessagesGrid;
        private TraceWatcher m_TraceWatcher;
        private BrowserWindow m_winBrowser;
        private CoordinatesWindow m_winCoordinates;
        private ResultsWindow m_winDebugWatch;
        private DependenciesWindow m_winDependencies;
        private QueryWindow m_winMdxScript;
        private MessagesWindow m_winMessages;
        private MetadataWindow m_winMetadata;
        private ParseWindow m_winParseTree;
        private PerfmonWindow m_winPerfmon;
        private ResultsWindow m_winResults;
        private TraceWindow m_winTrace;
        private ToolStripMenuItem mdxScriptToolStripMenuItem;
        private ToolStripMenuItem mDXToolStripMenuItem;
        private MenuStrip menuStripMain;
        private ToolStripMenuItem messagesToolStripMenuItem;
        private ToolStripMenuItem metadataToolStripMenuItem;
        private Settings mSettings;
        private TracerDlg mTraceDlg;
        private ToolStripMenuItem newQueryToolStripMenuItem;
        private ToolStripButton newToolStripButton;
        private ToolStripMenuItem onlineEditionToolStripMenuItem;
        private ToolStripMenuItem onlineToolStripMenuItem;
        private ToolStripButton openToolStripButton;
        private ToolStripMenuItem openToolStripMenuItem;
        private ToolStripMenuItem optionsToolStripMenuItem;
        private ToolStripMenuItem parseExpressionToolStripMenuItem;
        private ToolStripMenuItem parseToolStripMenuItem;
        private ToolStripMenuItem parseTreeToolStripMenuItem;
        private ToolStripMenuItem pasteContextMenuItem;
        private ToolStripButton pasteToolStripButton;
        private ToolStripMenuItem pasteToolStripMenuItem;
        private ToolStripMenuItem perfmonCountersToolStripMenuItem;
        private MDXStudio.PerfStats PerfStats;
        private ToolStripButton printToolStripButton;
        private ToolStripMenuItem profilerTraceToolStripMenuItem;
        private MDXStudio.QueryContext QueryContext;
        private ToolStripMenuItem questionToolStripMenuItem;
        private ToolStripMenuItem redoToolStripMenuItem;
        private ToolStripMenuItem replaceToolStripMenuItem;
        private ToolStripMenuItem resultsToolStripMenuItem;
        private RichTextBox richTextBox1;
        private ToolStripMenuItem saveAsToolStripMenuItem;
        private ToolStripButton saveToolStripButton;
        private ToolStripMenuItem saveToolStripMenuItem;
        private ToolStripMenuItem searchToolStripMenuItem;
        private ToolStripMenuItem showCoordinateOverwritesToolStripMenuItem;
        private ToolStripMenuItem startDebuggingToolStripMenuItem;
        private StatusStrip statusStrip1;
        private ToolStripMenuItem stopDebuggingToolStripMenuItem;
        private Timer timerQuery;
        private ToolStripMenuItem toolsToolStripMenuItem;
        private ToolStrip toolStrip;
        private ToolStripButton toolStripButtonAnalyze;
        private ToolStripButton toolStripButtonConnect;
        private ToolStripButton toolStripButtonCoord;
        private ToolStripButton toolStripButtonDebug;
        private ToolStripButton toolStripButtonDisconnect;
        private ToolStripButton toolStripButtonExecute;
        private ToolStripButton toolStripButtonFormat;
        private ToolStripButton toolStripButtonParse;
        private ToolStripButton toolStripButtonProfile;
        private ToolStripButton toolStripButtonStop;
        private ToolStripComboBox toolStripComboBoxCatalogs;
        private ToolStripComboBox toolStripComboBoxCubes;
        private ToolStrip toolStripCommon;
        private ToolStripContainer toolStripContainer1;
        private ToolStripLabel toolStripLabelCatalogs;
        private ToolStripLabel toolStripLabelCube;
        private ToolStripSeparator toolStripMenuItem1;
        private ToolStripSeparator toolStripSeparator;
        private ToolStripSeparator toolStripSeparator1;
        private ToolStripSeparator toolStripSeparator10;
        private ToolStripSeparator toolStripSeparator11;
        private ToolStripSeparator toolStripSeparator12;
        private ToolStripSeparator toolStripSeparator13;
        private ToolStripSeparator toolStripSeparator2;
        private ToolStripSeparator toolStripSeparator3;
        private ToolStripSeparator toolStripSeparator4;
        private ToolStripSeparator toolStripSeparator5;
        private ToolStripSeparator toolStripSeparator6;
        private ToolStripSeparator toolStripSeparator7;
        private ToolStripSeparator toolStripSeparator8;
        private ToolStripSeparator toolStripSeparator9;
        private ToolStripStatusLabel toolStripStatusLabel;
        private ToolStripStatusLabel toolStripStatusLabelCol;
        private ToolStripStatusLabel toolStripStatusLabelEmpty;
        private ToolStripStatusLabel toolStripStatusLabelLine;
        private ToolStripStatusLabel toolStripStatusLabelTimer;
        private ToolStripMenuItem traceToolStripMenuItem;
        private DataGridViewTextBoxColumn TreeGridColumnDuration;
        private TreeGridColumn TreeGridColumnEvent;
        private DataGridViewTextBoxColumn TreeGridColumnRatioToParent;
        private DataGridViewTextBoxColumn TreeGridColumnRatioToTotal;
        private TreeGridView treeGridViewTrace;
        private ToolStripMenuItem uncommentToolStripMenuItem;
        private ToolStripMenuItem undoToolStripMenuItem;
        private ToolStripMenuItem viewToolStripMenuItem;
        private ToolStripMenuItem windowToolStripMenuItem;

        public MainForm(string[] args)
        {
            this.InitializeComponent();
            this.m_Args = args;
        }

        private void aboutMDXStudioToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new AboutBox().Show();
        }

        private string BuildMemberTooltip(Member member)
        {
            string str = "Name: " + member.Name + "\nUnique name: " + member.UniqueName + "\nDescription: " + member.Description + "\nLevel name: " + member.LevelName;
            for (int i = 0; i < member.MemberProperties.Count; i++)
            {
                object obj2 = str;
                str = string.Concat(new object[] { obj2, "\n", member.MemberProperties[i].Name, ": ", member.MemberProperties[i].Value });
            }
            return str;
        }

        private void ClearCache()
        {
            if (this.toolStripComboBoxCatalogs.SelectedIndex < 0)
            {
                throw new Exception("Database is not selected");
            }
            string str = this.toolStripComboBoxCatalogs.Items[this.toolStripComboBoxCatalogs.SelectedIndex].ToString();
            if (string.IsNullOrEmpty(str))
            {
                throw new Exception("Database is not selected");
            }
            if (this.toolStripComboBoxCubes.SelectedIndex < 0)
            {
                throw new Exception("Cube is not selected");
            }
            string name = ((MdCube) this.toolStripComboBoxCubes.Items[this.toolStripComboBoxCubes.SelectedIndex]).Name;
            if (string.IsNullOrEmpty(name))
            {
                throw new Exception("Cube is not selected");
            }
            if (this.m_Connection.AMOConnection == null)
            {
                throw new Exception("Cannot clear cache without having AMO connection");
            }
            Database database = this.m_Connection.AMOConnection.get_Databases().FindByName(str);
            Cube cube = database.get_Cubes().FindByName(name);
            if (cube == null)
            {
                foreach (Cube cube2 in database.get_Cubes())
                {
                    if (cube2.get_Perspectives().FindByName(name) != null)
                    {
                        cube = cube2;
                        break;
                    }
                }
            }
            if (cube == null)
            {
                throw new Exception(string.Format("Cannot find cube or perspective {0}", name));
            }
            string format = "\r\n<Batch xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">\r\n  <ClearCache>\r\n    <Object>\r\n      <DatabaseID>{0}</DatabaseID>   \r\n      <CubeID>{1}</CubeID>\r\n    </Object>\r\n  </ClearCache>\r\n</Batch>\r\n                ";
            string str4 = string.Format(format, database.get_ID(), cube.get_ID());
            AdomdCommand command = this.m_Connection.QueryConnection.CreateCommand();
            command.CommandText = str4;
            command.ExecuteNonQuery();
            this.m_MessagesGrid.WriteMessage(string.Format("Cleared cache for cube '{0}'", cube));
        }

        private void clearCachesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                this.ClearCache();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Clear Cache", MessageBoxButtons.OK);
            }
        }

        public void ClearDebugWatch()
        {
            this.m_winDebugWatch.DataGridView.Columns.Clear();
            this.m_winDebugWatch.DataGridView.Rows.Clear();
            if (this.m_DebugWatch != null)
            {
                this.m_DebugWatch.Clear();
            }
        }

        public void ClearMessages()
        {
            this.m_MessagesGrid.Clear();
        }

        public void ClearResults()
        {
            this.m_winResults.DataGridView.Columns.Clear();
            this.m_winResults.DataGridView.Rows.Clear();
            this.ClearMessages();
        }

        private void commentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
            if (currentMdxEditor != null)
            {
                int lineFromCharIndex = currentMdxEditor.GetLineFromCharIndex(currentMdxEditor.SelectionStart);
                int num2 = currentMdxEditor.GetLineFromCharIndex(currentMdxEditor.SelectionStart + currentMdxEditor.SelectionLength);
                currentMdxEditor.SelectionLength = 0;
                for (int i = lineFromCharIndex; i <= num2; i++)
                {
                    int firstCharIndexFromLine = currentMdxEditor.GetFirstCharIndexFromLine(i);
                    currentMdxEditor.SelectionStart = firstCharIndexFromLine;
                    currentMdxEditor.SelectedText = "//";
                    currentMdxEditor.SelectionLength = 0;
                }
            }
        }

        private void Connect()
        {
            ConnectionDialog dialog = new ConnectionDialog();
            dialog.textBoxServerName.Text = this.mSettings.Connection_Server;
            dialog.textBoxConnectionProperties.Text = this.mSettings.Connection_Options;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                base.SuspendLayout();
                try
                {
                    this.m_Connection.ServerName = dialog.textBoxServerName.Text;
                    this.mSettings.Connection_Server = this.m_Connection.ServerName;
                    this.mSettings.Connection_Options = dialog.textBoxConnectionProperties.Text;
                    this.mSettings.Save();
                    this.ClearMessages();
                    this.m_MessagesGrid.WriteMessage("Connecting to server '" + this.m_Connection.ServerName + "'...");
                    this.Cursor = Cursors.WaitCursor;
                    this.m_ConnectionString = string.Format("Data Source={0};Application Name=MDX Studio v{1}", this.m_Connection.ServerName, "0.4.14.0");
                    if (!string.IsNullOrEmpty(dialog.textBoxRoles.Text))
                    {
                        this.m_ConnectionString = this.m_ConnectionString + ";Roles=" + dialog.textBoxRoles.Text;
                    }
                    if (!string.IsNullOrEmpty(dialog.textBoxEffectiveUserName.Text))
                    {
                        this.m_ConnectionString = this.m_ConnectionString + ";EffectiveUserName=" + dialog.textBoxEffectiveUserName.Text;
                    }
                    if (dialog.comboBoxUniqueNameStyle.SelectedItem != null)
                    {
                        string[] strArray = dialog.comboBoxUniqueNameStyle.SelectedItem.ToString().Split(new char[] { ' ' });
                        this.m_ConnectionString = this.m_ConnectionString + ";MDX Unique Name Style=" + strArray[0];
                    }
                    if (dialog.comboBoxMDXCompatibility.SelectedItem != null)
                    {
                        string[] strArray2 = dialog.comboBoxMDXCompatibility.SelectedItem.ToString().Split(new char[] { ' ' });
                        this.m_ConnectionString = this.m_ConnectionString + ";MDX Compatibility=" + strArray2[0];
                    }
                    if (dialog.comboBoxMissingMembers.SelectedItem != null)
                    {
                        string[] strArray3 = dialog.comboBoxMissingMembers.SelectedItem.ToString().Split(new char[] { ' ' });
                        this.m_ConnectionString = this.m_ConnectionString + ";MDX Missing Member Mode=" + strArray3[0];
                    }
                    if (dialog.comboBoxVisualMode.SelectedItem != null)
                    {
                        string[] strArray4 = dialog.comboBoxVisualMode.SelectedItem.ToString().Split(new char[] { ' ' });
                        this.m_ConnectionString = this.m_ConnectionString + ";Default MDX Visual Mode=" + strArray4[0];
                    }
                    this.m_ConnectionString = this.m_ConnectionString + ";" + dialog.textBoxConnectionProperties.Text;
                    this.m_Connection.MetadataConnection = new AdomdConnection(this.m_ConnectionString);
                    this.m_Connection.MetadataConnection.Open();
                    this.m_Connection.QueryConnection = new AdomdConnection(this.m_ConnectionString);
                    this.m_Connection.QueryConnection.Open();
                    try
                    {
                        this.m_Connection.AMOConnection = new Server();
                        this.m_Connection.AMOConnection.Connect(this.m_ConnectionString);
                        this.m_TraceWatcher.m_AMO = this.m_Connection.AMOConnection;
                    }
                    catch (Exception)
                    {
                        this.m_Connection.AMOConnection = null;
                    }
                    try
                    {
                        this.m_Connection.TraceConnection = new Server();
                        this.m_Connection.TraceConnection.Connect(this.m_Connection.QueryConnection.ConnectionString, this.m_Connection.QueryConnection.SessionID);
                        this.m_Connection.TraceConnection.get_SessionTrace().add_OnEvent(new TraceEventHandler(this, (IntPtr) this.SessionTrace_OnEvent));
                        this.m_Connection.TraceConnection.get_SessionTrace().Start();
                    }
                    catch (Exception)
                    {
                        this.m_Connection.TraceConnection = null;
                    }
                    this.Cursor = Cursors.Default;
                    this.m_MessagesGrid.WriteMessage("Connected to '" + this.m_Connection.ServerName + "'.");
                    this.toolStripStatusLabel.Text = string.Format("Connected to {0}", this.m_Connection.ServerName);
                    this.m_winMetadata.Show();
                    this.toolStripComboBoxCatalogs.Items.Clear();
                    this.m_winMetadata.TreeViewMetadata.Nodes.Clear();
                    this.m_winMetadata.TreeBuilder.Conn = this.m_Connection.MetadataConnection;
                    this.toolStripComboBoxCatalogs.AutoSize = true;
                    this.FillList(this.toolStripComboBoxCatalogs.Items, "DBSCHEMA_CATALOGS", null, "CATALOG_NAME");
                    if (0 < this.toolStripComboBoxCatalogs.Items.Count)
                    {
                        this.toolStripComboBoxCatalogs.SelectedIndex = this.toolStripComboBoxCatalogs.FindStringExact(this.m_Connection.MetadataConnection.Database);
                    }
                    if (0 < this.toolStripComboBoxCubes.Items.Count)
                    {
                        this.toolStripComboBoxCubes.SelectedIndex = 0;
                    }
                    this.toolStripButtonConnect.Enabled = false;
                    this.toolStripButtonDisconnect.Enabled = true;
                    this.toolStripButtonExecute.Enabled = true;
                    this.toolStripButtonDebug.Enabled = true;
                    this.toolStripButtonStop.Enabled = true;
                    this.toolStripComboBoxCatalogs.Enabled = true;
                    this.toolStripComboBoxCubes.Enabled = true;
                    this.traceToolStripMenuItem.Enabled = true;
                }
                catch (Exception exception)
                {
                    this.m_MessagesGrid.WriteErrorMessage(exception.Message);
                    this.Cursor = Cursors.Default;
                }
                base.ResumeLayout();
            }
        }

        private void coordinatesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.m_winCoordinates.Show(this.dockPanel);
        }

        private void copyContextMenuItem_Click(object sender, EventArgs e)
        {
            this.ProcessCopy();
        }

        private void copyToolStripButton_Click(object sender, EventArgs e)
        {
            this.ProcessCopy();
        }

        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.ProcessCopy();
        }

        private void cutContextMenuItem_Click(object sender, EventArgs e)
        {
            this.ProcessCut();
        }

        private void cutToolStripButton_Click(object sender, EventArgs e)
        {
            this.ProcessCut();
        }

        private void cutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.ProcessCut();
        }

        private void dataGridCellSet_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            this.GridQueryResults.CellDoubleClick(sender, e);
        }

        private void dataGridCellSet_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if ((this.toolStripComboBoxCubes.SelectedIndex >= 0) && this.m_fDebugMode)
                {
                    string cube = this.toolStripComboBoxCubes.Items[this.toolStripComboBoxCubes.SelectedIndex].ToString();
                    this.GridQueryResults.CellEnter(sender, e, this.m_Connection.QueryConnection, cube);
                    this.ClearDebugWatch();
                    this.UpdateDebugWatch();
                    this.m_winCoordinates.ListAxes.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                }
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
        }

        private void dataGridCellSet_Scroll(object sender, ScrollEventArgs e)
        {
            try
            {
                this.GridQueryResults.Scroll(e);
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
        }

        private void dataGridDebugWatch_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            try
            {
                this.GridDebugWatch.CellValueNeeded(sender, e);
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
        }

        private void DebugModeOff()
        {
            this.m_fDebugMode = false;
            this.startDebuggingToolStripMenuItem.Enabled = true;
            this.stopDebuggingToolStripMenuItem.Enabled = false;
        }

        private void DebugModeOn()
        {
            this.m_fDebugMode = true;
            this.startDebuggingToolStripMenuItem.Enabled = false;
            this.stopDebuggingToolStripMenuItem.Enabled = true;
        }

        private void debugToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.toolStripButtonDebug_Click(null, null);
        }

        private void debugWatchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.m_winDebugWatch.Show(this.dockPanel);
        }

        private void dependenciesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.m_winDependencies.Show(this.dockPanel);
        }

        private void Disconnect()
        {
            if (this.m_Connection.MetadataConnection != null)
            {
                this.m_Connection.MetadataConnection.Close(true);
                this.m_Connection.MetadataConnection = null;
            }
            if (this.m_Connection.QueryConnection != null)
            {
                this.m_Connection.QueryConnection.Close(true);
                this.m_Connection.QueryConnection = null;
            }
            if (this.m_Connection.AMOConnection != null)
            {
                this.m_Connection.AMOConnection.Disconnect();
                this.m_Connection.AMOConnection = null;
            }
            if (this.m_Connection.TraceConnection != null)
            {
                if (this.m_Connection.TraceConnection.get_SessionTrace().get_IsStarted())
                {
                    this.m_Connection.TraceConnection.get_SessionTrace().Stop();
                }
                this.m_Connection.TraceConnection.Disconnect();
                this.m_Connection.TraceConnection = null;
            }
            this.m_Connection.ServerName = "";
            this.toolStripButtonConnect.Enabled = true;
            this.toolStripButtonDisconnect.Enabled = false;
            this.toolStripButtonExecute.Enabled = false;
            this.toolStripButtonDebug.Enabled = false;
            this.toolStripButtonStop.Enabled = false;
            this.toolStripComboBoxCatalogs.Items.Clear();
            this.toolStripComboBoxCatalogs.Enabled = false;
            this.toolStripComboBoxCubes.Items.Clear();
            this.toolStripComboBoxCubes.Enabled = false;
            this.m_winMetadata.TreeViewMetadata.Nodes.Clear();
            this.traceToolStripMenuItem.Enabled = false;
            this.m_winParseTree.ParseTreeView.Nodes.Clear();
            if (this.mTraceDlg != null)
            {
                this.mTraceDlg.Close();
                this.mTraceDlg = null;
            }
            this.toolStripStatusLabel.Text = "Not connected";
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void editor_SelectionChanged(object sender, EventArgs e)
        {
            MdxEditor editor = sender as MdxEditor;
            int num = editor.GetLineFromCharIndex(editor.SelectionStart) + 1;
            int num2 = (editor.SelectionStart - editor.GetFirstCharIndexOfCurrentLine()) + 1;
            this.toolStripStatusLabelLine.Text = "Line " + num.ToString();
            this.toolStripStatusLabelCol.Text = "Col " + num2.ToString();
        }

        private void editToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
            if (currentMdxEditor != null)
            {
                this.undoToolStripMenuItem.Enabled = currentMdxEditor.UndoEnabled;
                this.redoToolStripMenuItem.Enabled = currentMdxEditor.RedoEnabled;
            }
        }

        private void executeQueryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.toolStripButtonExecute_Click(null, null);
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                this.toolStripButtonReconnect_Click(null, null);
                base.Close();
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
        }

        private void feedbackToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                this.GotoDefaultWebBrowser("http://www.ssas-info.com/forum/posting.php?mode=post&f=3");
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
        }

        private void FillList(ComboBox.ObjectCollection target, string schema, AdomdRestrictionCollection restrictions, string column)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                foreach (DataTable table in this.m_Connection.MetadataConnection.GetSchemaDataSet(schema, restrictions).Tables)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        if (schema == "MDSCHEMA_CUBES")
                        {
                            MdCube item = new MdCube(row);
                            target.Add(item);
                        }
                        else
                        {
                            target.Add(row[column].ToString());
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }

        private void FillNode(System.Windows.Forms.TreeNodeCollection target, string schema, AdomdRestrictionCollection restrictions, string column, string name, string child)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                foreach (DataTable table in this.m_Connection.MetadataConnection.GetSchemaDataSet(schema, restrictions).Tables)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        string str = null;
                        string str2 = null;
                        if ("MDSCHEMA_DIMENSIONS" == schema)
                        {
                            if (2 == Convert.ToInt32(row["DIMENSION_TYPE"]))
                            {
                                continue;
                            }
                            str = "Dimension";
                        }
                        else if ("MDSCHEMA_HIERARCHIES" == schema)
                        {
                            str2 = row["HIERARCHY_DISPLAY_FOLDER"].ToString();
                            switch (Convert.ToInt32(row["HIERARCHY_ORIGIN"]))
                            {
                                case 1:
                                    str = "Hierarchy";
                                    break;

                                case 2:
                                    str = "AttributeHierarchy";
                                    break;

                                case 3:
                                    str = "ParentChild";
                                    break;

                                case 6:
                                    str = "AttributeKey";
                                    break;
                            }
                        }
                        else if ("MDSCHEMA_LEVELS" == schema)
                        {
                            str = "Level" + Convert.ToString((int) (Convert.ToInt32(row["LEVEL_NUMBER"]) + 1));
                        }
                        else if ("MDSCHEMA_MEASURES" == schema)
                        {
                            str2 = row["MEASURE_DISPLAY_FOLDER"].ToString();
                            if (str2.Length == 0)
                            {
                                str2 = row["MEASUREGROUP_NAME"].ToString();
                            }
                            if (0x7f == Convert.ToInt32(row["MEASURE_AGGREGATOR"]))
                            {
                                str = "MeasureCalculated";
                            }
                            else
                            {
                                str = "Measure";
                            }
                        }
                        else if ("MDSCHEMA_KPIS" == schema)
                        {
                            str2 = row["KPI_DISPLAY_FOLDER"].ToString();
                            str = "Kpi";
                        }
                        System.Windows.Forms.TreeNode node = null;
                        if ((str2 != null) && (str2.Length > 0))
                        {
                            string[] strArray = str2.Split(new char[] { '\\' });
                            System.Windows.Forms.TreeNode node2 = null;
                            System.Windows.Forms.TreeNodeCollection nodes = target;
                            foreach (string str3 in strArray)
                            {
                                node2 = null;
                                System.Windows.Forms.TreeNode[] nodeArray = nodes.Find(str3, true);
                                if (nodeArray.Length > 0)
                                {
                                    node2 = nodeArray[0];
                                }
                                else
                                {
                                    node2 = nodes.Add(str3, str3);
                                    node2.ImageKey = node2.SelectedImageKey = "FolderClosed.ico";
                                }
                                nodes = node2.Nodes;
                            }
                            node = node2.Nodes.Add(row[column].ToString());
                        }
                        else
                        {
                            node = target.Add(row[column].ToString());
                        }
                        node.Name = row[name].ToString();
                        node.ImageKey = str + ".ico";
                        node.SelectedImageKey = str + ".ico";
                        if (child != null)
                        {
                            node.Nodes.Add(child);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }

        private void findToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
            if (currentMdxEditor != null)
            {
                currentMdxEditor.NewSearch(false);
            }
        }

        private void FormatClick(bool IsExpression)
        {
            try
            {
                MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
                if (currentMdxEditor != null)
                {
                    int selectionLength = currentMdxEditor.SelectionLength;
                    this.ClearMessages();
                    MDXParser.MDXParser parser = this.Parse(null, false, IsExpression, true);
                    if (parser != null)
                    {
                        FormatOptions fo = new FormatOptions(this.m_formatOptions);
                        fo.Output = OutputFormat.Text;
                        string str = parser.FormatMDX(fo);
                        if (selectionLength > 0)
                        {
                            currentMdxEditor.SelectedText = str;
                        }
                        else
                        {
                            currentMdxEditor.Text = str;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
        }

        private void formatExpressionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.FormatClick(true);
        }

        private void formatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.FormatClick(false);
        }

        private void forumToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                this.GotoDefaultWebBrowser("http://www.ssas-info.com/forum/MDXStudio");
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
        }

        private MdxEditor GetCurrentMdxEditor()
        {
            QueryWindow currentQueryWindow = this.GetCurrentQueryWindow();
            if (currentQueryWindow != null)
            {
                return currentQueryWindow.MDXEditor;
            }
            return null;
        }

        private QueryWindow GetCurrentQueryWindow()
        {
            if ((this.dockPanel.ActiveDocument == null) || (this.dockPanel.ActiveDocument.GetType() != typeof(QueryWindow)))
            {
                return null;
            }
            return (this.dockPanel.ActiveDocument as QueryWindow);
        }

        private System.Windows.Forms.TreeNode GetParseTreeNode(string name)
        {
            foreach (System.Windows.Forms.TreeNode node in this.m_winParseTree.ParseTreeView.Nodes)
            {
                if (node.Text.Equals(name, StringComparison.InvariantCultureIgnoreCase))
                {
                    return node;
                }
            }
            System.Windows.Forms.TreeNode node2 = this.m_winParseTree.ParseTreeView.Nodes.Add(name);
            node2.ImageKey = node2.SelectedImageKey = name.StartsWith("Que") ? "MdxQuery.ico" : "Script.ico";
            return node2;
        }

        public void GotoDefaultWebBrowser(string url)
        {
            this.m_winBrowser.WebBrowser.Navigate(url);
            this.m_winBrowser.Show(this.dockPanel);
        }

        private void helpToolStripButton_Click(object sender, EventArgs e)
        {
            this.aboutMDXStudioToolStripMenuItem_Click(sender, e);
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(MainForm));
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            this.imageListMetadata = new ImageList(this.components);
            this.imageListTabs = new ImageList(this.components);
            this.toolStrip = new ToolStrip();
            this.toolStripButtonConnect = new ToolStripButton();
            this.toolStripButtonDisconnect = new ToolStripButton();
            this.toolStripSeparator1 = new ToolStripSeparator();
            this.toolStripLabelCatalogs = new ToolStripLabel();
            this.toolStripComboBoxCatalogs = new ToolStripComboBox();
            this.toolStripLabelCube = new ToolStripLabel();
            this.toolStripComboBoxCubes = new ToolStripComboBox();
            this.toolStripButtonExecute = new ToolStripButton();
            this.toolStripButtonStop = new ToolStripButton();
            this.toolStripButtonDebug = new ToolStripButton();
            this.toolStripButtonProfile = new ToolStripButton();
            this.toolStripSeparator3 = new ToolStripSeparator();
            this.toolStripButtonParse = new ToolStripButton();
            this.toolStripButtonFormat = new ToolStripButton();
            this.toolStripButtonAnalyze = new ToolStripButton();
            this.toolStripButtonCoord = new ToolStripButton();
            this.richTextBox1 = new RichTextBox();
            this.dataGridView1 = new DataGridView();
            this.menuStripMain = new MenuStrip();
            this.fileToolStripMenuItem = new ToolStripMenuItem();
            this.newQueryToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator12 = new ToolStripSeparator();
            this.openToolStripMenuItem = new ToolStripMenuItem();
            this.saveToolStripMenuItem = new ToolStripMenuItem();
            this.saveAsToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator2 = new ToolStripSeparator();
            this.exitToolStripMenuItem = new ToolStripMenuItem();
            this.editToolStripMenuItem = new ToolStripMenuItem();
            this.undoToolStripMenuItem = new ToolStripMenuItem();
            this.redoToolStripMenuItem = new ToolStripMenuItem();
            this.findToolStripMenuItem = new ToolStripMenuItem();
            this.replaceToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator8 = new ToolStripSeparator();
            this.cutToolStripMenuItem = new ToolStripMenuItem();
            this.copyToolStripMenuItem = new ToolStripMenuItem();
            this.pasteToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator9 = new ToolStripSeparator();
            this.commentToolStripMenuItem = new ToolStripMenuItem();
            this.uncommentToolStripMenuItem = new ToolStripMenuItem();
            this.viewToolStripMenuItem = new ToolStripMenuItem();
            this.mdxScriptToolStripMenuItem = new ToolStripMenuItem();
            this.dependenciesToolStripMenuItem = new ToolStripMenuItem();
            this.profilerTraceToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator11 = new ToolStripSeparator();
            this.metadataToolStripMenuItem = new ToolStripMenuItem();
            this.parseTreeToolStripMenuItem = new ToolStripMenuItem();
            this.perfmonCountersToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator10 = new ToolStripSeparator();
            this.messagesToolStripMenuItem = new ToolStripMenuItem();
            this.resultsToolStripMenuItem = new ToolStripMenuItem();
            this.coordinatesToolStripMenuItem = new ToolStripMenuItem();
            this.debugWatchToolStripMenuItem = new ToolStripMenuItem();
            this.mDXToolStripMenuItem = new ToolStripMenuItem();
            this.executeQueryToolStripMenuItem = new ToolStripMenuItem();
            this.debugToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator5 = new ToolStripSeparator();
            this.clearCachesToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator7 = new ToolStripSeparator();
            this.parseToolStripMenuItem = new ToolStripMenuItem();
            this.formatToolStripMenuItem = new ToolStripMenuItem();
            this.parseExpressionToolStripMenuItem = new ToolStripMenuItem();
            this.formatExpressionToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator6 = new ToolStripSeparator();
            this.showCoordinateOverwritesToolStripMenuItem = new ToolStripMenuItem();
            this.debugToolStripMenuItem1 = new ToolStripMenuItem();
            this.startDebuggingToolStripMenuItem = new ToolStripMenuItem();
            this.stopDebuggingToolStripMenuItem = new ToolStripMenuItem();
            this.toolsToolStripMenuItem = new ToolStripMenuItem();
            this.traceToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripMenuItem1 = new ToolStripSeparator();
            this.optionsToolStripMenuItem = new ToolStripMenuItem();
            this.windowToolStripMenuItem = new ToolStripMenuItem();
            this.communityToolStripMenuItem = new ToolStripMenuItem();
            this.forumToolStripMenuItem = new ToolStripMenuItem();
            this.feedbackToolStripMenuItem = new ToolStripMenuItem();
            this.questionToolStripMenuItem = new ToolStripMenuItem();
            this.onlineToolStripMenuItem = new ToolStripMenuItem();
            this.onlineEditionToolStripMenuItem = new ToolStripMenuItem();
            this.helpToolStripMenuItem = new ToolStripMenuItem();
            this.searchToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator4 = new ToolStripSeparator();
            this.aboutMDXStudioToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripContainer1 = new ToolStripContainer();
            this.statusStrip1 = new StatusStrip();
            this.toolStripStatusLabel = new ToolStripStatusLabel();
            this.toolStripStatusLabelLine = new ToolStripStatusLabel();
            this.toolStripStatusLabelCol = new ToolStripStatusLabel();
            this.toolStripStatusLabelEmpty = new ToolStripStatusLabel();
            this.dockPanel = new DockPanel();
            this.toolStripCommon = new ToolStrip();
            this.newToolStripButton = new ToolStripButton();
            this.openToolStripButton = new ToolStripButton();
            this.saveToolStripButton = new ToolStripButton();
            this.printToolStripButton = new ToolStripButton();
            this.toolStripSeparator = new ToolStripSeparator();
            this.cutToolStripButton = new ToolStripButton();
            this.copyToolStripButton = new ToolStripButton();
            this.pasteToolStripButton = new ToolStripButton();
            this.toolStripSeparator13 = new ToolStripSeparator();
            this.helpToolStripButton = new ToolStripButton();
            this.contextMenuStripEdit = new ContextMenuStrip(this.components);
            this.cutContextMenuItem = new ToolStripMenuItem();
            this.copyContextMenuItem = new ToolStripMenuItem();
            this.pasteContextMenuItem = new ToolStripMenuItem();
            this.treeGridViewTrace = new TreeGridView();
            this.TreeGridColumnEvent = new TreeGridColumn();
            this.TreeGridColumnDuration = new DataGridViewTextBoxColumn();
            this.TreeGridColumnRatioToTotal = new DataGridViewTextBoxColumn();
            this.TreeGridColumnRatioToParent = new DataGridViewTextBoxColumn();
            this.imageListTraceEvents = new ImageList(this.components);
            this.toolStripStatusLabelTimer = new ToolStripStatusLabel();
            this.timerQuery = new Timer(this.components);
            this.toolStrip.SuspendLayout();
            ((ISupportInitialize) this.dataGridView1).BeginInit();
            this.menuStripMain.SuspendLayout();
            this.toolStripContainer1.BottomToolStripPanel.SuspendLayout();
            this.toolStripContainer1.ContentPanel.SuspendLayout();
            this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
            this.toolStripContainer1.SuspendLayout();
            this.statusStrip1.SuspendLayout();
            this.toolStripCommon.SuspendLayout();
            this.contextMenuStripEdit.SuspendLayout();
            ((ISupportInitialize) this.treeGridViewTrace).BeginInit();
            base.SuspendLayout();
            this.imageListMetadata.ImageStream = (ImageListStreamer) manager.GetObject("imageListMetadata.ImageStream");
            this.imageListMetadata.TransparentColor = Color.Transparent;
            this.imageListMetadata.Images.SetKeyName(0, "Cube.ico");
            this.imageListMetadata.Images.SetKeyName(1, "Dimension.ico");
            this.imageListMetadata.Images.SetKeyName(2, "Measure.ico");
            this.imageListMetadata.Images.SetKeyName(3, "MeasureCalculated.ico");
            this.imageListMetadata.Images.SetKeyName(4, "Kpi.ico");
            this.imageListMetadata.Images.SetKeyName(5, "FolderOpen.ico");
            this.imageListMetadata.Images.SetKeyName(6, "FolderClosed.ico");
            this.imageListMetadata.Images.SetKeyName(7, "Hierarchy.ico");
            this.imageListMetadata.Images.SetKeyName(8, "ParentChild.ico");
            this.imageListMetadata.Images.SetKeyName(9, "AttributeHierarchy.ico");
            this.imageListMetadata.Images.SetKeyName(10, "Level1.ico");
            this.imageListMetadata.Images.SetKeyName(11, "Level2.ico");
            this.imageListMetadata.Images.SetKeyName(12, "Level3.ico");
            this.imageListMetadata.Images.SetKeyName(13, "Level4.ico");
            this.imageListMetadata.Images.SetKeyName(14, "Level5.ico");
            this.imageListMetadata.Images.SetKeyName(15, "Level6.ico");
            this.imageListMetadata.Images.SetKeyName(0x10, "Level7.ico");
            this.imageListMetadata.Images.SetKeyName(0x11, "Level8.ico");
            this.imageListMetadata.Images.SetKeyName(0x12, "Level9.ico");
            this.imageListMetadata.Images.SetKeyName(0x13, "Level10.ico");
            this.imageListMetadata.Images.SetKeyName(20, "Level11.ico");
            this.imageListMetadata.Images.SetKeyName(0x15, "Level12.ico");
            this.imageListMetadata.Images.SetKeyName(0x16, "Level13.ico");
            this.imageListMetadata.Images.SetKeyName(0x17, "Level14.ico");
            this.imageListMetadata.Images.SetKeyName(0x18, "Level15.ico");
            this.imageListMetadata.Images.SetKeyName(0x19, "Level16.ico");
            this.imageListMetadata.Images.SetKeyName(0x1a, "NamedSet.ico");
            this.imageListMetadata.Images.SetKeyName(0x1b, "MDXQuery.ico");
            this.imageListMetadata.Images.SetKeyName(0x1c, "AttributeKey.ico");
            this.imageListMetadata.Images.SetKeyName(0x1d, "Member.ico");
            this.imageListMetadata.Images.SetKeyName(30, "ParentChildDisabled.ico");
            this.imageListMetadata.Images.SetKeyName(0x1f, "AttributeKeyDisabled.ico");
            this.imageListMetadata.Images.SetKeyName(0x20, "AttributeWithDisabledHierarchy.ico");
            this.imageListMetadata.Images.SetKeyName(0x21, "Script.ico");
            this.imageListMetadata.Images.SetKeyName(0x22, "CellCalculation.ico");
            this.imageListMetadata.Images.SetKeyName(0x23, "Scope.ico");
            this.imageListTabs.ImageStream = (ImageListStreamer) manager.GetObject("imageListTabs.ImageStream");
            this.imageListTabs.TransparentColor = Color.Transparent;
            this.imageListTabs.Images.SetKeyName(0, "Metadata.ico");
            this.imageListTabs.Images.SetKeyName(1, "TreeView.ico");
            this.imageListTabs.Images.SetKeyName(2, "PerfMon.ico");
            this.imageListTabs.Images.SetKeyName(3, "MDXQuery.ico");
            this.imageListTabs.Images.SetKeyName(4, "Script.ico");
            this.imageListTabs.Images.SetKeyName(5, "StrongHierarchy.ico");
            this.toolStrip.Items.AddRange(new ToolStripItem[] { this.toolStripButtonConnect, this.toolStripButtonDisconnect, this.toolStripSeparator1, this.toolStripLabelCatalogs, this.toolStripComboBoxCatalogs, this.toolStripLabelCube, this.toolStripComboBoxCubes, this.toolStripButtonExecute, this.toolStripButtonStop, this.toolStripButtonDebug, this.toolStripButtonProfile, this.toolStripSeparator3, this.toolStripButtonParse, this.toolStripButtonFormat, this.toolStripButtonAnalyze, this.toolStripButtonCoord });
            this.toolStrip.Location = new Point(0, 0x18);
            this.toolStrip.Name = "toolStrip";
            this.toolStrip.Size = new Size(0x424, 0x19);
            this.toolStrip.TabIndex = 2;
            this.toolStrip.Text = "toolStrip1";
            this.toolStripButtonConnect.Image = (Image) manager.GetObject("toolStripButtonConnect.Image");
            this.toolStripButtonConnect.ImageTransparentColor = Color.Magenta;
            this.toolStripButtonConnect.Name = "toolStripButtonConnect";
            this.toolStripButtonConnect.Size = new Size(0x43, 0x16);
            this.toolStripButtonConnect.Text = "&Connect";
            this.toolStripButtonConnect.Click += new EventHandler(this.toolStripButtonConnect_Click);
            this.toolStripButtonDisconnect.DisplayStyle = ToolStripItemDisplayStyle.Text;
            this.toolStripButtonDisconnect.Image = (Image) manager.GetObject("toolStripButtonDisconnect.Image");
            this.toolStripButtonDisconnect.ImageTransparentColor = Color.Magenta;
            this.toolStripButtonDisconnect.Name = "toolStripButtonDisconnect";
            //this.toolStripButtonDisconnect.RightToLeft = RightToLeft.Yes;
            this.toolStripButtonDisconnect.Size = new Size(0x3e, 0x16);
            this.toolStripButtonDisconnect.Text = "Reconnect";
            this.toolStripButtonDisconnect.Click += new EventHandler(this.toolStripButtonReconnect_Click);
            this.toolStripSeparator1.Name = "toolStripSeparator1";
            this.toolStripSeparator1.Size = new Size(6, 0x19);
            this.toolStripLabelCatalogs.Name = "toolStripLabelCatalogs";
            this.toolStripLabelCatalogs.Size = new Size(0x2c, 0x16);
            this.toolStripLabelCatalogs.Text = "Catalog";
            this.toolStripComboBoxCatalogs.DropDownStyle = ComboBoxStyle.DropDownList;
            this.toolStripComboBoxCatalogs.Name = "toolStripComboBoxCatalogs";
            this.toolStripComboBoxCatalogs.Size = new Size(150, 0x19);
            this.toolStripComboBoxCatalogs.SelectedIndexChanged += new EventHandler(this.toolStripComboBoxCatalogs_SelectedIndexChanged);
            this.toolStripLabelCube.Name = "toolStripLabelCube";
            this.toolStripLabelCube.Size = new Size(0x20, 0x16);
            this.toolStripLabelCube.Text = "Cube";
            this.toolStripComboBoxCubes.DropDownStyle = ComboBoxStyle.DropDownList;
            this.toolStripComboBoxCubes.Name = "toolStripComboBoxCubes";
            this.toolStripComboBoxCubes.Size = new Size(200, 0x19);
            this.toolStripComboBoxCubes.SelectedIndexChanged += new EventHandler(this.toolStripComboBoxCubes_SelectedIndexChanged);
            this.toolStripButtonExecute.Image = (Image) manager.GetObject("toolStripButtonExecute.Image");
            this.toolStripButtonExecute.ImageTransparentColor = Color.Magenta;
            this.toolStripButtonExecute.Name = "toolStripButtonExecute";
            this.toolStripButtonExecute.Size = new Size(0x42, 0x16);
            this.toolStripButtonExecute.Text = "E&xecute";
            this.toolStripButtonExecute.ToolTipText = "Execute query";
            this.toolStripButtonExecute.Click += new EventHandler(this.toolStripButtonExecute_Click);
            this.toolStripButtonStop.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.toolStripButtonStop.Image = (Image) manager.GetObject("toolStripButtonStop.Image");
            this.toolStripButtonStop.ImageTransparentColor = Color.Magenta;
            this.toolStripButtonStop.Name = "toolStripButtonStop";
            this.toolStripButtonStop.Size = new Size(0x17, 0x16);
            this.toolStripButtonStop.Text = "toolStripButton1";
            this.toolStripButtonStop.ToolTipText = "Cancel the query";
            this.toolStripButtonStop.Click += new EventHandler(this.toolStripButtonStop_Click);
            this.toolStripButtonDebug.Image = (Image) manager.GetObject("toolStripButtonDebug.Image");
            this.toolStripButtonDebug.ImageTransparentColor = Color.Magenta;
            this.toolStripButtonDebug.Name = "toolStripButtonDebug";
            this.toolStripButtonDebug.Size = new Size(0x3a, 0x16);
            this.toolStripButtonDebug.Text = "Debug";
            this.toolStripButtonDebug.Click += new EventHandler(this.toolStripButtonDebug_Click);
            this.toolStripButtonProfile.Image = (Image) manager.GetObject("toolStripButtonProfile.Image");
            this.toolStripButtonProfile.ImageTransparentColor = Color.Magenta;
            this.toolStripButtonProfile.Name = "toolStripButtonProfile";
            this.toolStripButtonProfile.Size = new Size(0x39, 0x16);
            this.toolStripButtonProfile.Text = "Profile";
            this.toolStripButtonProfile.Click += new EventHandler(this.toolStripButtonProfile_Click);
            this.toolStripSeparator3.Name = "toolStripSeparator3";
            this.toolStripSeparator3.Size = new Size(6, 0x19);
            this.toolStripButtonParse.Image = (Image) manager.GetObject("toolStripButtonParse.Image");
            this.toolStripButtonParse.ImageTransparentColor = Color.Magenta;
            this.toolStripButtonParse.Name = "toolStripButtonParse";
            this.toolStripButtonParse.Size = new Size(0x36, 0x16);
            this.toolStripButtonParse.Text = "&Parse";
            this.toolStripButtonParse.ToolTipText = "Parse MDX Expression";
            this.toolStripButtonParse.Click += new EventHandler(this.toolStripButtonParse_Click);
            this.toolStripButtonFormat.Image = (Image) manager.GetObject("toolStripButtonFormat.Image");
            this.toolStripButtonFormat.ImageTransparentColor = Color.Magenta;
            this.toolStripButtonFormat.Name = "toolStripButtonFormat";
            this.toolStripButtonFormat.Size = new Size(0x3d, 0x16);
            this.toolStripButtonFormat.Text = "Fo&rmat";
            this.toolStripButtonFormat.Click += new EventHandler(this.toolStripButtonFormat_Click);
            this.toolStripButtonAnalyze.Image = (Image) manager.GetObject("toolStripButtonAnalyze.Image");
            this.toolStripButtonAnalyze.ImageTransparentColor = Color.Magenta;
            this.toolStripButtonAnalyze.Name = "toolStripButtonAnalyze";
            this.toolStripButtonAnalyze.Size = new Size(0x41, 0x16);
            this.toolStripButtonAnalyze.Text = "&Analyze";
            this.toolStripButtonAnalyze.Click += new EventHandler(this.toolStripButtonAnalyze_Click);
            this.toolStripButtonCoord.Image = (Image) manager.GetObject("toolStripButtonCoord.Image");
            this.toolStripButtonCoord.ImageTransparentColor = Color.Magenta;
            this.toolStripButtonCoord.Name = "toolStripButtonCoord";
            this.toolStripButtonCoord.Size = new Size(0x55, 0x16);
            this.toolStripButtonCoord.Text = "Coordinates";
            this.toolStripButtonCoord.Click += new EventHandler(this.toolStripButtonCoord_Click);
            this.richTextBox1.Dock = DockStyle.Fill;
            this.richTextBox1.Font = new Font("Courier New", 12f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.richTextBox1.Location = new Point(0, 0);
            this.richTextBox1.Name = "richTextBox1";
            this.richTextBox1.Size = new Size(0x2e0, 0xe5);
            this.richTextBox1.TabIndex = 0;
            this.richTextBox1.Text = "";
            this.dataGridView1.AllowUserToAddRows = false;
            this.dataGridView1.AllowUserToDeleteRows = false;
            this.dataGridView1.AllowUserToResizeColumns = false;
            this.dataGridView1.AllowUserToResizeRows = false;
            this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            this.dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
            this.dataGridView1.BackgroundColor = SystemColors.Window;
            this.dataGridView1.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
            this.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dataGridView1.ColumnHeadersVisible = false;
            this.dataGridView1.Dock = DockStyle.Fill;
            this.dataGridView1.Location = new Point(0, 0);
            this.dataGridView1.Name = "dataGridView1";
            this.dataGridView1.ReadOnly = true;
            this.dataGridView1.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
            this.dataGridView1.RowHeadersVisible = false;
            this.dataGridView1.SelectionMode = DataGridViewSelectionMode.CellSelect;
            this.dataGridView1.Size = new Size(0x2e0, 0x11c);
            this.dataGridView1.TabIndex = 0;
            this.menuStripMain.AllowMerge = false;
            this.menuStripMain.Items.AddRange(new ToolStripItem[] { this.fileToolStripMenuItem, this.editToolStripMenuItem, this.viewToolStripMenuItem, this.mDXToolStripMenuItem, this.debugToolStripMenuItem1, this.toolsToolStripMenuItem, this.windowToolStripMenuItem, this.communityToolStripMenuItem, this.onlineToolStripMenuItem, this.helpToolStripMenuItem });
            this.menuStripMain.Location = new Point(0, 0);
            this.menuStripMain.Name = "menuStripMain";
            this.menuStripMain.Size = new Size(0x424, 0x18);
            this.menuStripMain.TabIndex = 3;
            this.menuStripMain.Text = "menuStripMain";
            this.fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.newQueryToolStripMenuItem, this.toolStripSeparator12, this.openToolStripMenuItem, this.saveToolStripMenuItem, this.saveAsToolStripMenuItem, this.toolStripSeparator2, this.exitToolStripMenuItem });
            this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
            this.fileToolStripMenuItem.Size = new Size(0x23, 20);
            this.fileToolStripMenuItem.Text = "&File";
            this.newQueryToolStripMenuItem.Name = "newQueryToolStripMenuItem";
            this.newQueryToolStripMenuItem.Size = new Size(0x97, 0x16);
            this.newQueryToolStripMenuItem.Text = "New Query";
            this.newQueryToolStripMenuItem.Click += new EventHandler(this.newQueryToolStripMenuItem_Click);
            this.toolStripSeparator12.Name = "toolStripSeparator12";
            this.toolStripSeparator12.Size = new Size(0x94, 6);
            this.openToolStripMenuItem.Image = (Image) manager.GetObject("openToolStripMenuItem.Image");
            this.openToolStripMenuItem.Name = "openToolStripMenuItem";
            this.openToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O;
            this.openToolStripMenuItem.Size = new Size(0x97, 0x16);
            this.openToolStripMenuItem.Text = "&Open";
            this.openToolStripMenuItem.Click += new EventHandler(this.openToolStripMenuItem_Click);
            this.saveToolStripMenuItem.Image = (Image) manager.GetObject("saveToolStripMenuItem.Image");
            this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
            this.saveToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S;
            this.saveToolStripMenuItem.Size = new Size(0x97, 0x16);
            this.saveToolStripMenuItem.Text = "&Save";
            this.saveToolStripMenuItem.Click += new EventHandler(this.saveToolStripMenuItem_Click);
            this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
            this.saveAsToolStripMenuItem.Size = new Size(0x97, 0x16);
            this.saveAsToolStripMenuItem.Text = "Save As ...";
            this.saveAsToolStripMenuItem.Click += new EventHandler(this.saveAsToolStripMenuItem_Click);
            this.toolStripSeparator2.Name = "toolStripSeparator2";
            this.toolStripSeparator2.Size = new Size(0x94, 6);
            this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
            this.exitToolStripMenuItem.Size = new Size(0x97, 0x16);
            this.exitToolStripMenuItem.Text = "&Exit";
            this.exitToolStripMenuItem.Click += new EventHandler(this.exitToolStripMenuItem_Click);
            this.editToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.undoToolStripMenuItem, this.redoToolStripMenuItem, this.findToolStripMenuItem, this.replaceToolStripMenuItem, this.toolStripSeparator8, this.cutToolStripMenuItem, this.copyToolStripMenuItem, this.pasteToolStripMenuItem, this.toolStripSeparator9, this.commentToolStripMenuItem, this.uncommentToolStripMenuItem });
            this.editToolStripMenuItem.Name = "editToolStripMenuItem";
            this.editToolStripMenuItem.Size = new Size(0x25, 20);
            this.editToolStripMenuItem.Text = "&Edit";
            this.editToolStripMenuItem.DropDownOpening += new EventHandler(this.editToolStripMenuItem_DropDownOpening);
            this.undoToolStripMenuItem.Name = "undoToolStripMenuItem";
            this.undoToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z;
            this.undoToolStripMenuItem.Size = new Size(0xba, 0x16);
            this.undoToolStripMenuItem.Text = "&Undo";
            this.undoToolStripMenuItem.Click += new EventHandler(this.undoToolStripMenuItem_Click);
            this.redoToolStripMenuItem.Name = "redoToolStripMenuItem";
            this.redoToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y;
            this.redoToolStripMenuItem.Size = new Size(0xba, 0x16);
            this.redoToolStripMenuItem.Text = "&Redo";
            this.redoToolStripMenuItem.Click += new EventHandler(this.redoToolStripMenuItem_Click);
            this.findToolStripMenuItem.Image = (Image) manager.GetObject("findToolStripMenuItem.Image");
            this.findToolStripMenuItem.Name = "findToolStripMenuItem";
            this.findToolStripMenuItem.Size = new Size(0xba, 0x16);
            this.findToolStripMenuItem.Text = "&Find";
            this.findToolStripMenuItem.Click += new EventHandler(this.findToolStripMenuItem_Click);
            this.replaceToolStripMenuItem.Name = "replaceToolStripMenuItem";
            this.replaceToolStripMenuItem.Size = new Size(0xba, 0x16);
            this.replaceToolStripMenuItem.Text = "Replace";
            this.replaceToolStripMenuItem.Click += new EventHandler(this.replaceToolStripMenuItem_Click);
            this.toolStripSeparator8.Name = "toolStripSeparator8";
            this.toolStripSeparator8.Size = new Size(0xb7, 6);
            this.cutToolStripMenuItem.Image = (Image) manager.GetObject("cutToolStripMenuItem.Image");
            this.cutToolStripMenuItem.Name = "cutToolStripMenuItem";
            this.cutToolStripMenuItem.Size = new Size(0xba, 0x16);
            this.cutToolStripMenuItem.Text = "Cut";
            this.cutToolStripMenuItem.Click += new EventHandler(this.cutToolStripMenuItem_Click);
            this.copyToolStripMenuItem.Image = (Image) manager.GetObject("copyToolStripMenuItem.Image");
            this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
            this.copyToolStripMenuItem.Size = new Size(0xba, 0x16);
            this.copyToolStripMenuItem.Text = "Copy";
            this.copyToolStripMenuItem.Click += new EventHandler(this.copyToolStripMenuItem_Click);
            this.pasteToolStripMenuItem.Image = (Image) manager.GetObject("pasteToolStripMenuItem.Image");
            this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
            this.pasteToolStripMenuItem.Size = new Size(0xba, 0x16);
            this.pasteToolStripMenuItem.Text = "Paste";
            this.pasteToolStripMenuItem.Click += new EventHandler(this.pasteToolStripMenuItem_Click);
            this.toolStripSeparator9.Name = "toolStripSeparator9";
            this.toolStripSeparator9.Size = new Size(0xb7, 6);
            this.commentToolStripMenuItem.Name = "commentToolStripMenuItem";
            this.commentToolStripMenuItem.Size = new Size(0xba, 0x16);
            this.commentToolStripMenuItem.Text = "Comment selection";
            this.commentToolStripMenuItem.Click += new EventHandler(this.commentToolStripMenuItem_Click);
            this.uncommentToolStripMenuItem.Name = "uncommentToolStripMenuItem";
            this.uncommentToolStripMenuItem.Size = new Size(0xba, 0x16);
            this.uncommentToolStripMenuItem.Text = "Uncomment selection";
            this.uncommentToolStripMenuItem.Click += new EventHandler(this.uncommentToolStripMenuItem_Click);
            this.viewToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.mdxScriptToolStripMenuItem, this.dependenciesToolStripMenuItem, this.profilerTraceToolStripMenuItem, this.toolStripSeparator11, this.metadataToolStripMenuItem, this.parseTreeToolStripMenuItem, this.perfmonCountersToolStripMenuItem, this.toolStripSeparator10, this.messagesToolStripMenuItem, this.resultsToolStripMenuItem, this.coordinatesToolStripMenuItem, this.debugWatchToolStripMenuItem });
            this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
            this.viewToolStripMenuItem.Size = new Size(0x29, 20);
            this.viewToolStripMenuItem.Text = "&View";
            this.mdxScriptToolStripMenuItem.Image = (Image) manager.GetObject("mdxScriptToolStripMenuItem.Image");
            this.mdxScriptToolStripMenuItem.Name = "mdxScriptToolStripMenuItem";
            this.mdxScriptToolStripMenuItem.Size = new Size(170, 0x16);
            this.mdxScriptToolStripMenuItem.Text = "MDX Script";
            this.mdxScriptToolStripMenuItem.Click += new EventHandler(this.mdxScriptToolStripMenuItem_Click);
            this.dependenciesToolStripMenuItem.Image = (Image) manager.GetObject("dependenciesToolStripMenuItem.Image");
            this.dependenciesToolStripMenuItem.Name = "dependenciesToolStripMenuItem";
            this.dependenciesToolStripMenuItem.Size = new Size(170, 0x16);
            this.dependenciesToolStripMenuItem.Text = "Dependencies";
            this.dependenciesToolStripMenuItem.Click += new EventHandler(this.dependenciesToolStripMenuItem_Click);
            this.profilerTraceToolStripMenuItem.Image = (Image) manager.GetObject("profilerTraceToolStripMenuItem.Image");
            this.profilerTraceToolStripMenuItem.Name = "profilerTraceToolStripMenuItem";
            this.profilerTraceToolStripMenuItem.Size = new Size(170, 0x16);
            this.profilerTraceToolStripMenuItem.Text = "Profiler trace";
            this.profilerTraceToolStripMenuItem.Click += new EventHandler(this.profilerTraceToolStripMenuItem_Click);
            this.toolStripSeparator11.Name = "toolStripSeparator11";
            this.toolStripSeparator11.Size = new Size(0xa7, 6);
            this.metadataToolStripMenuItem.Image = (Image) manager.GetObject("metadataToolStripMenuItem.Image");
            this.metadataToolStripMenuItem.Name = "metadataToolStripMenuItem";
            this.metadataToolStripMenuItem.Size = new Size(170, 0x16);
            this.metadataToolStripMenuItem.Text = "Metadata";
            this.metadataToolStripMenuItem.Click += new EventHandler(this.metadataToolStripMenuItem_Click);
            this.parseTreeToolStripMenuItem.Image = (Image) manager.GetObject("parseTreeToolStripMenuItem.Image");
            this.parseTreeToolStripMenuItem.Name = "parseTreeToolStripMenuItem";
            this.parseTreeToolStripMenuItem.Size = new Size(170, 0x16);
            this.parseTreeToolStripMenuItem.Text = "Parse tree";
            this.parseTreeToolStripMenuItem.Click += new EventHandler(this.parseTreeToolStripMenuItem_Click);
            this.perfmonCountersToolStripMenuItem.Image = (Image) manager.GetObject("perfmonCountersToolStripMenuItem.Image");
            this.perfmonCountersToolStripMenuItem.Name = "perfmonCountersToolStripMenuItem";
            this.perfmonCountersToolStripMenuItem.Size = new Size(170, 0x16);
            this.perfmonCountersToolStripMenuItem.Text = "Perfmon counters";
            this.perfmonCountersToolStripMenuItem.Click += new EventHandler(this.perfmonCountersToolStripMenuItem_Click);
            this.toolStripSeparator10.Name = "toolStripSeparator10";
            this.toolStripSeparator10.Size = new Size(0xa7, 6);
            this.messagesToolStripMenuItem.Image = (Image) manager.GetObject("messagesToolStripMenuItem.Image");
            this.messagesToolStripMenuItem.Name = "messagesToolStripMenuItem";
            this.messagesToolStripMenuItem.Size = new Size(170, 0x16);
            this.messagesToolStripMenuItem.Text = "Messages";
            this.messagesToolStripMenuItem.Click += new EventHandler(this.messagesToolStripMenuItem_Click);
            this.resultsToolStripMenuItem.Image = (Image) manager.GetObject("resultsToolStripMenuItem.Image");
            this.resultsToolStripMenuItem.Name = "resultsToolStripMenuItem";
            this.resultsToolStripMenuItem.Size = new Size(170, 0x16);
            this.resultsToolStripMenuItem.Text = "Results";
            this.resultsToolStripMenuItem.Click += new EventHandler(this.resultsToolStripMenuItem_Click);
            this.coordinatesToolStripMenuItem.Image = (Image) manager.GetObject("coordinatesToolStripMenuItem.Image");
            this.coordinatesToolStripMenuItem.Name = "coordinatesToolStripMenuItem";
            this.coordinatesToolStripMenuItem.Size = new Size(170, 0x16);
            this.coordinatesToolStripMenuItem.Text = "Coordinates";
            this.coordinatesToolStripMenuItem.Click += new EventHandler(this.coordinatesToolStripMenuItem_Click);
            this.debugWatchToolStripMenuItem.Image = (Image) manager.GetObject("debugWatchToolStripMenuItem.Image");
            this.debugWatchToolStripMenuItem.Name = "debugWatchToolStripMenuItem";
            this.debugWatchToolStripMenuItem.Size = new Size(170, 0x16);
            this.debugWatchToolStripMenuItem.Text = "Debug Watch";
            this.debugWatchToolStripMenuItem.Click += new EventHandler(this.debugWatchToolStripMenuItem_Click);
            this.mDXToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.executeQueryToolStripMenuItem, this.debugToolStripMenuItem, this.toolStripSeparator5, this.clearCachesToolStripMenuItem, this.toolStripSeparator7, this.parseToolStripMenuItem, this.formatToolStripMenuItem, this.parseExpressionToolStripMenuItem, this.formatExpressionToolStripMenuItem, this.toolStripSeparator6, this.showCoordinateOverwritesToolStripMenuItem });
            this.mDXToolStripMenuItem.Name = "mDXToolStripMenuItem";
            this.mDXToolStripMenuItem.Size = new Size(40, 20);
            this.mDXToolStripMenuItem.Text = "&MDX";
            this.executeQueryToolStripMenuItem.Image = (Image) manager.GetObject("executeQueryToolStripMenuItem.Image");
            this.executeQueryToolStripMenuItem.Name = "executeQueryToolStripMenuItem";
            this.executeQueryToolStripMenuItem.Size = new Size(0xdb, 0x16);
            this.executeQueryToolStripMenuItem.Text = "Execute query";
            this.executeQueryToolStripMenuItem.Click += new EventHandler(this.executeQueryToolStripMenuItem_Click);
            this.debugToolStripMenuItem.Name = "debugToolStripMenuItem";
            this.debugToolStripMenuItem.Size = new Size(0xdb, 0x16);
            this.debugToolStripMenuItem.Text = "Debug query";
            this.debugToolStripMenuItem.Click += new EventHandler(this.debugToolStripMenuItem_Click);
            this.toolStripSeparator5.Name = "toolStripSeparator5";
            this.toolStripSeparator5.Size = new Size(0xd8, 6);
            this.clearCachesToolStripMenuItem.Image = (Image) manager.GetObject("clearCachesToolStripMenuItem.Image");
            this.clearCachesToolStripMenuItem.Name = "clearCachesToolStripMenuItem";
            this.clearCachesToolStripMenuItem.Size = new Size(0xdb, 0x16);
            this.clearCachesToolStripMenuItem.Text = "Clear caches";
            this.clearCachesToolStripMenuItem.Click += new EventHandler(this.clearCachesToolStripMenuItem_Click);
            this.toolStripSeparator7.Name = "toolStripSeparator7";
            this.toolStripSeparator7.Size = new Size(0xd8, 6);
            this.parseToolStripMenuItem.Image = (Image) manager.GetObject("parseToolStripMenuItem.Image");
            this.parseToolStripMenuItem.Name = "parseToolStripMenuItem";
            this.parseToolStripMenuItem.Size = new Size(0xdb, 0x16);
            this.parseToolStripMenuItem.Text = "Parse";
            this.parseToolStripMenuItem.Click += new EventHandler(this.parseToolStripMenuItem_Click);
            this.formatToolStripMenuItem.Image = (Image) manager.GetObject("formatToolStripMenuItem.Image");
            this.formatToolStripMenuItem.Name = "formatToolStripMenuItem";
            this.formatToolStripMenuItem.Size = new Size(0xdb, 0x16);
            this.formatToolStripMenuItem.Text = "&Format";
            this.formatToolStripMenuItem.Click += new EventHandler(this.formatToolStripMenuItem_Click);
            this.parseExpressionToolStripMenuItem.Name = "parseExpressionToolStripMenuItem";
            this.parseExpressionToolStripMenuItem.Size = new Size(0xdb, 0x16);
            this.parseExpressionToolStripMenuItem.Text = "Parse expression";
            this.parseExpressionToolStripMenuItem.Click += new EventHandler(this.parseExpressionToolStripMenuItem_Click);
            this.formatExpressionToolStripMenuItem.Name = "formatExpressionToolStripMenuItem";
            this.formatExpressionToolStripMenuItem.Size = new Size(0xdb, 0x16);
            this.formatExpressionToolStripMenuItem.Text = "Format expression";
            this.formatExpressionToolStripMenuItem.Click += new EventHandler(this.formatExpressionToolStripMenuItem_Click);
            this.toolStripSeparator6.Name = "toolStripSeparator6";
            this.toolStripSeparator6.Size = new Size(0xd8, 6);
            this.showCoordinateOverwritesToolStripMenuItem.Name = "showCoordinateOverwritesToolStripMenuItem";
            this.showCoordinateOverwritesToolStripMenuItem.Size = new Size(0xdb, 0x16);
            this.showCoordinateOverwritesToolStripMenuItem.Text = "Show coordinate overwrites";
            this.showCoordinateOverwritesToolStripMenuItem.Click += new EventHandler(this.showCoordinateOverwritesToolStripMenuItem_Click);
            this.debugToolStripMenuItem1.DropDownItems.AddRange(new ToolStripItem[] { this.startDebuggingToolStripMenuItem, this.stopDebuggingToolStripMenuItem });
            this.debugToolStripMenuItem1.Name = "debugToolStripMenuItem1";
            this.debugToolStripMenuItem1.Size = new Size(50, 20);
            this.debugToolStripMenuItem1.Text = "&Debug";
            this.startDebuggingToolStripMenuItem.Image = (Image) manager.GetObject("startDebuggingToolStripMenuItem.Image");
            this.startDebuggingToolStripMenuItem.Name = "startDebuggingToolStripMenuItem";
            this.startDebuggingToolStripMenuItem.Size = new Size(0xa3, 0x16);
            this.startDebuggingToolStripMenuItem.Text = "Start Debugging";
            this.startDebuggingToolStripMenuItem.Click += new EventHandler(this.startDebuggingToolStripMenuItem_Click);
            this.stopDebuggingToolStripMenuItem.Image = (Image) manager.GetObject("stopDebuggingToolStripMenuItem.Image");
            this.stopDebuggingToolStripMenuItem.Name = "stopDebuggingToolStripMenuItem";
            this.stopDebuggingToolStripMenuItem.Size = new Size(0xa3, 0x16);
            this.stopDebuggingToolStripMenuItem.Text = "Stop Debugging";
            this.stopDebuggingToolStripMenuItem.Click += new EventHandler(this.stopDebuggingToolStripMenuItem_Click);
            this.toolsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.traceToolStripMenuItem, this.toolStripMenuItem1, this.optionsToolStripMenuItem });
            this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem";
            this.toolsToolStripMenuItem.Size = new Size(0x2c, 20);
            this.toolsToolStripMenuItem.Text = "&Tools";
            this.traceToolStripMenuItem.Enabled = false;
            this.traceToolStripMenuItem.Name = "traceToolStripMenuItem";
            this.traceToolStripMenuItem.Size = new Size(0x86, 0x16);
            this.traceToolStripMenuItem.Text = "&Trace";
            this.traceToolStripMenuItem.Click += new EventHandler(this.traceToolStripMenuItem_Click);
            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
            this.toolStripMenuItem1.Size = new Size(0x83, 6);
            this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
            this.optionsToolStripMenuItem.Size = new Size(0x86, 0x16);
            this.optionsToolStripMenuItem.Text = "Options...";
            this.optionsToolStripMenuItem.Click += new EventHandler(this.optionsToolStripMenuItem_Click);
            this.windowToolStripMenuItem.Name = "windowToolStripMenuItem";
            this.windowToolStripMenuItem.Size = new Size(0x39, 20);
            this.windowToolStripMenuItem.Text = "&Window";
            this.communityToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.forumToolStripMenuItem, this.feedbackToolStripMenuItem, this.questionToolStripMenuItem });
            this.communityToolStripMenuItem.Name = "communityToolStripMenuItem";
            this.communityToolStripMenuItem.Size = new Size(0x48, 20);
            this.communityToolStripMenuItem.Text = "&Community";
            this.forumToolStripMenuItem.Name = "forumToolStripMenuItem";
            this.forumToolStripMenuItem.Size = new Size(0xc2, 0x16);
            this.forumToolStripMenuItem.Text = "Ask Question in forum";
            this.forumToolStripMenuItem.Click += new EventHandler(this.forumToolStripMenuItem_Click);
            this.feedbackToolStripMenuItem.Name = "feedbackToolStripMenuItem";
            this.feedbackToolStripMenuItem.Size = new Size(0xc2, 0x16);
            this.feedbackToolStripMenuItem.Text = "Send Feedback";
            this.feedbackToolStripMenuItem.Click += new EventHandler(this.feedbackToolStripMenuItem_Click);
            this.questionToolStripMenuItem.Name = "questionToolStripMenuItem";
            this.questionToolStripMenuItem.Size = new Size(0xc2, 0x16);
            this.questionToolStripMenuItem.Text = "Check Question Status";
            this.questionToolStripMenuItem.Click += new EventHandler(this.questionToolStripMenuItem_Click);
            this.onlineToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.onlineEditionToolStripMenuItem });
            this.onlineToolStripMenuItem.Name = "onlineToolStripMenuItem";
            this.onlineToolStripMenuItem.Size = new Size(0x31, 20);
            this.onlineToolStripMenuItem.Text = "Online";
            this.onlineEditionToolStripMenuItem.Name = "onlineEditionToolStripMenuItem";
            this.onlineEditionToolStripMenuItem.Size = new Size(150, 0x16);
            this.onlineEditionToolStripMenuItem.Text = "Online edition";
            this.onlineEditionToolStripMenuItem.Click += new EventHandler(this.onlineEditionToolStripMenuItem_Click);
            this.helpToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.searchToolStripMenuItem, this.toolStripSeparator4, this.aboutMDXStudioToolStripMenuItem });
            this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
            this.helpToolStripMenuItem.Size = new Size(40, 20);
            this.helpToolStripMenuItem.Text = "&Help";
            this.searchToolStripMenuItem.Name = "searchToolStripMenuItem";
            this.searchToolStripMenuItem.Size = new Size(0xab, 0x16);
            this.searchToolStripMenuItem.Text = "Search";
            this.searchToolStripMenuItem.Click += new EventHandler(this.searchToolStripMenuItem_Click);
            this.toolStripSeparator4.Name = "toolStripSeparator4";
            this.toolStripSeparator4.Size = new Size(0xa8, 6);
            this.aboutMDXStudioToolStripMenuItem.Name = "aboutMDXStudioToolStripMenuItem";
            this.aboutMDXStudioToolStripMenuItem.Size = new Size(0xab, 0x16);
            this.aboutMDXStudioToolStripMenuItem.Text = "About MDX Studio";
            this.aboutMDXStudioToolStripMenuItem.Click += new EventHandler(this.aboutMDXStudioToolStripMenuItem_Click);
            this.toolStripContainer1.BottomToolStripPanel.Controls.Add(this.statusStrip1);
            this.toolStripContainer1.ContentPanel.Controls.Add(this.dockPanel);
            this.toolStripContainer1.ContentPanel.Size = new Size(0x424, 610);
            this.toolStripContainer1.Dock = DockStyle.Fill;
            this.toolStripContainer1.Location = new Point(0, 0x31);
            this.toolStripContainer1.Name = "toolStripContainer1";
            this.toolStripContainer1.Size = new Size(0x424, 0x291);
            this.toolStripContainer1.TabIndex = 6;
            this.toolStripContainer1.Text = "toolStripContainer1";
            this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.toolStripCommon);
            this.statusStrip1.Dock = DockStyle.None;
            this.statusStrip1.Items.AddRange(new ToolStripItem[] { this.toolStripStatusLabel, this.toolStripStatusLabelLine, this.toolStripStatusLabelCol, this.toolStripStatusLabelEmpty, this.toolStripStatusLabelTimer });
            this.statusStrip1.Location = new Point(0, 0);
            this.statusStrip1.Name = "statusStrip1";
            this.statusStrip1.Size = new Size(0x424, 0x16);
            this.statusStrip1.TabIndex = 0;
            this.toolStripStatusLabel.Name = "toolStripStatusLabel";
            this.toolStripStatusLabel.Size = new Size(0x4d, 0x11);
            this.toolStripStatusLabel.Text = "Not connected";
            this.toolStripStatusLabelLine.DisplayStyle = ToolStripItemDisplayStyle.Text;
            this.toolStripStatusLabelLine.Name = "toolStripStatusLabelLine";
            this.toolStripStatusLabelLine.Size = new Size(0x309, 0x11);
            this.toolStripStatusLabelLine.Spring = true;
            this.toolStripStatusLabelLine.TextAlign = ContentAlignment.MiddleRight;
            this.toolStripStatusLabelCol.AutoSize = false;
            this.toolStripStatusLabelCol.Name = "toolStripStatusLabelCol";
            this.toolStripStatusLabelCol.Size = new Size(70, 0x11);
            this.toolStripStatusLabelCol.TextAlign = ContentAlignment.MiddleRight;
            this.toolStripStatusLabelEmpty.AutoSize = false;
            this.toolStripStatusLabelEmpty.Name = "toolStripStatusLabelEmpty";
            this.toolStripStatusLabelEmpty.Size = new Size(70, 0x11);
            this.dockPanel.ActiveAutoHideContent = null;
            this.dockPanel.Dock = DockStyle.Fill;
            this.dockPanel.DocumentStyle = DocumentStyle.DockingWindow;
            this.dockPanel.Location = new Point(0, 0);
            this.dockPanel.Name = "dockPanel";
            this.dockPanel.ShowDocumentIcon = true;
            this.dockPanel.Size = new Size(0x424, 610);
            this.dockPanel.TabIndex = 5;
            this.toolStripCommon.Dock = DockStyle.None;
            this.toolStripCommon.Items.AddRange(new ToolStripItem[] { this.newToolStripButton, this.openToolStripButton, this.saveToolStripButton, this.printToolStripButton, this.toolStripSeparator, this.cutToolStripButton, this.copyToolStripButton, this.pasteToolStripButton, this.toolStripSeparator13, this.helpToolStripButton });
            this.toolStripCommon.Location = new Point(3, 0);
            this.toolStripCommon.Name = "toolStripCommon";
            this.toolStripCommon.Size = new Size(0x108, 0x19);
            this.toolStripCommon.TabIndex = 0;
            this.newToolStripButton.Image = (Image) manager.GetObject("newToolStripButton.Image");
            this.newToolStripButton.ImageTransparentColor = Color.Magenta;
            this.newToolStripButton.Name = "newToolStripButton";
            this.newToolStripButton.Size = new Size(0x51, 0x16);
            this.newToolStripButton.Text = "&New Query";
            this.newToolStripButton.Click += new EventHandler(this.newToolStripButton_Click);
            this.openToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.openToolStripButton.Image = (Image) manager.GetObject("openToolStripButton.Image");
            this.openToolStripButton.ImageTransparentColor = Color.Magenta;
            this.openToolStripButton.Name = "openToolStripButton";
            this.openToolStripButton.Size = new Size(0x17, 0x16);
            this.openToolStripButton.Text = "&Open";
            this.openToolStripButton.Click += new EventHandler(this.openToolStripButton_Click);
            this.saveToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.saveToolStripButton.Image = (Image) manager.GetObject("saveToolStripButton.Image");
            this.saveToolStripButton.ImageTransparentColor = Color.Magenta;
            this.saveToolStripButton.Name = "saveToolStripButton";
            this.saveToolStripButton.Size = new Size(0x17, 0x16);
            this.saveToolStripButton.Text = "&Save";
            this.saveToolStripButton.Click += new EventHandler(this.saveToolStripButton_Click);
            this.printToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.printToolStripButton.Enabled = false;
            this.printToolStripButton.Image = (Image) manager.GetObject("printToolStripButton.Image");
            this.printToolStripButton.ImageTransparentColor = Color.Magenta;
            this.printToolStripButton.Name = "printToolStripButton";
            this.printToolStripButton.Size = new Size(0x17, 0x16);
            this.printToolStripButton.Text = "&Print";
            this.toolStripSeparator.Name = "toolStripSeparator";
            this.toolStripSeparator.Size = new Size(6, 0x19);
            this.cutToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.cutToolStripButton.Image = (Image) manager.GetObject("cutToolStripButton.Image");
            this.cutToolStripButton.ImageTransparentColor = Color.Magenta;
            this.cutToolStripButton.Name = "cutToolStripButton";
            this.cutToolStripButton.Size = new Size(0x17, 0x16);
            this.cutToolStripButton.Text = "C&ut";
            this.cutToolStripButton.Click += new EventHandler(this.cutToolStripButton_Click);
            this.copyToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.copyToolStripButton.Image = (Image) manager.GetObject("copyToolStripButton.Image");
            this.copyToolStripButton.ImageTransparentColor = Color.Magenta;
            this.copyToolStripButton.Name = "copyToolStripButton";
            this.copyToolStripButton.Size = new Size(0x17, 0x16);
            this.copyToolStripButton.Text = "&Copy";
            this.copyToolStripButton.Click += new EventHandler(this.copyToolStripButton_Click);
            this.pasteToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.pasteToolStripButton.Image = (Image) manager.GetObject("pasteToolStripButton.Image");
            this.pasteToolStripButton.ImageTransparentColor = Color.Magenta;
            this.pasteToolStripButton.Name = "pasteToolStripButton";
            this.pasteToolStripButton.Size = new Size(0x17, 0x16);
            this.pasteToolStripButton.Text = "&Paste";
            this.pasteToolStripButton.Click += new EventHandler(this.pasteToolStripButton_Click);
            this.toolStripSeparator13.Name = "toolStripSeparator13";
            this.toolStripSeparator13.Size = new Size(6, 0x19);
            this.helpToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.helpToolStripButton.Image = (Image) manager.GetObject("helpToolStripButton.Image");
            this.helpToolStripButton.ImageTransparentColor = Color.Magenta;
            this.helpToolStripButton.Name = "helpToolStripButton";
            this.helpToolStripButton.Size = new Size(0x17, 0x16);
            this.helpToolStripButton.Text = "He&lp";
            this.helpToolStripButton.Click += new EventHandler(this.helpToolStripButton_Click);
            this.contextMenuStripEdit.Items.AddRange(new ToolStripItem[] { this.cutContextMenuItem, this.copyContextMenuItem, this.pasteContextMenuItem });
            this.contextMenuStripEdit.Name = "contextMenuStripEdit";
            this.contextMenuStripEdit.Size = new Size(0x71, 70);
            this.cutContextMenuItem.Image = (Image) manager.GetObject("cutContextMenuItem.Image");
            this.cutContextMenuItem.Name = "cutContextMenuItem";
            this.cutContextMenuItem.Size = new Size(0x70, 0x16);
            this.cutContextMenuItem.Text = "Cut";
            this.cutContextMenuItem.Click += new EventHandler(this.cutContextMenuItem_Click);
            this.copyContextMenuItem.Image = (Image) manager.GetObject("copyContextMenuItem.Image");
            this.copyContextMenuItem.Name = "copyContextMenuItem";
            this.copyContextMenuItem.Size = new Size(0x70, 0x16);
            this.copyContextMenuItem.Text = "Copy";
            this.copyContextMenuItem.Click += new EventHandler(this.copyContextMenuItem_Click);
            this.pasteContextMenuItem.Image = (Image) manager.GetObject("pasteContextMenuItem.Image");
            this.pasteContextMenuItem.Name = "pasteContextMenuItem";
            this.pasteContextMenuItem.Size = new Size(0x70, 0x16);
            this.pasteContextMenuItem.Text = "Paste";
            this.pasteContextMenuItem.Click += new EventHandler(this.pasteContextMenuItem_Click);
            this.treeGridViewTrace.AllowUserToAddRows = false;
            this.treeGridViewTrace.AllowUserToDeleteRows = false;
            this.treeGridViewTrace.AllowUserToOrderColumns = true;
            this.treeGridViewTrace.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            this.treeGridViewTrace.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells;
            this.treeGridViewTrace.CellBorderStyle = DataGridViewCellBorderStyle.None;
            style.Alignment = DataGridViewContentAlignment.MiddleLeft;
            style.BackColor = SystemColors.Control;
            style.Font = new Font("Tahoma", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
            style.ForeColor = SystemColors.WindowText;
            style.SelectionBackColor = SystemColors.Highlight;
            style.SelectionForeColor = SystemColors.HighlightText;
            style.WrapMode = DataGridViewTriState.True;
            this.treeGridViewTrace.ColumnHeadersDefaultCellStyle = style;
            this.treeGridViewTrace.Columns.AddRange(new DataGridViewColumn[] { this.TreeGridColumnEvent, this.TreeGridColumnDuration, this.TreeGridColumnRatioToTotal, this.TreeGridColumnRatioToParent });
            this.treeGridViewTrace.Dock = DockStyle.Fill;
            this.treeGridViewTrace.EditMode = DataGridViewEditMode.EditProgrammatically;
            this.treeGridViewTrace.ImageList = this.imageListTraceEvents;
            this.treeGridViewTrace.Location = new Point(3, 3);
            this.treeGridViewTrace.Name = "treeGridViewTrace";
            this.treeGridViewTrace.RowHeadersVisible = false;
            this.treeGridViewTrace.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this.treeGridViewTrace.Size = new Size(0x1b4, 0x106);
            this.treeGridViewTrace.TabIndex = 0;
            this.TreeGridColumnEvent.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.TreeGridColumnEvent.DefaultNodeImage = null;
            this.TreeGridColumnEvent.HeaderText = "Event";
            this.TreeGridColumnEvent.Name = "TreeGridColumnEvent";
            this.TreeGridColumnEvent.ReadOnly = true;
            this.TreeGridColumnEvent.SortMode = DataGridViewColumnSortMode.NotSortable;
            this.TreeGridColumnDuration.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
            this.TreeGridColumnDuration.FillWeight = 30f;
            this.TreeGridColumnDuration.HeaderText = "Duration";
            this.TreeGridColumnDuration.Name = "TreeGridColumnDuration";
            this.TreeGridColumnDuration.ReadOnly = true;
            this.TreeGridColumnDuration.SortMode = DataGridViewColumnSortMode.NotSortable;
            this.TreeGridColumnDuration.Width = 0x36;
            this.TreeGridColumnRatioToTotal.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
            this.TreeGridColumnRatioToTotal.FillWeight = 30f;
            this.TreeGridColumnRatioToTotal.HeaderText = "Ratio to Total";
            this.TreeGridColumnRatioToTotal.Name = "TreeGridColumnRatioToTotal";
            this.TreeGridColumnRatioToTotal.SortMode = DataGridViewColumnSortMode.NotSortable;
            this.TreeGridColumnRatioToTotal.Width = 0x4e;
            this.TreeGridColumnRatioToParent.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
            this.TreeGridColumnRatioToParent.FillWeight = 30f;
            this.TreeGridColumnRatioToParent.HeaderText = "Ratio to Parent";
            this.TreeGridColumnRatioToParent.Name = "TreeGridColumnRatioToParent";
            this.TreeGridColumnRatioToParent.SortMode = DataGridViewColumnSortMode.NotSortable;
            this.TreeGridColumnRatioToParent.Width = 0x56;
            this.imageListTraceEvents.ImageStream = (ImageListStreamer) manager.GetObject("imageListTraceEvents.ImageStream");
            this.imageListTraceEvents.TransparentColor = Color.Transparent;
            this.imageListTraceEvents.Images.SetKeyName(0, "Run.ico");
            this.imageListTraceEvents.Images.SetKeyName(1, "MDXQuery.ico");
            this.imageListTraceEvents.Images.SetKeyName(2, "Partition.ico");
            this.imageListTraceEvents.Images.SetKeyName(3, "Cube.ico");
            this.imageListTraceEvents.Images.SetKeyName(4, "NamedSet.ico");
            this.imageListTraceEvents.Images.SetKeyName(5, "Script.ico");
            this.imageListTraceEvents.Images.SetKeyName(6, "Cache.ico");
            this.imageListTraceEvents.Images.SetKeyName(7, "Aggregate.ico");
            this.toolStripStatusLabelTimer.Name = "toolStripStatusLabelTimer";
            this.toolStripStatusLabelTimer.Size = new Size(0x33, 0x11);
            this.toolStripStatusLabelTimer.Text = "0:0:0.0";
            this.timerQuery.Tick += new EventHandler(this.timerQuery_Tick);
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            //base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x424, 0x2c2);
            base.Controls.Add(this.toolStripContainer1);
            base.Controls.Add(this.toolStrip);
            base.Controls.Add(this.menuStripMain);
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.MainMenuStrip = this.menuStripMain;
            base.Name = "MainForm";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "MDX Studio by Mosha Pasumansky";
            base.WindowState = FormWindowState.Maximized;
            base.Load += new EventHandler(this.MainForm_Load);
            base.FormClosing += new FormClosingEventHandler(this.MainForm_FormClosing);
            this.toolStrip.ResumeLayout(false);
            this.toolStrip.PerformLayout();
            ((ISupportInitialize) this.dataGridView1).EndInit();
            this.menuStripMain.ResumeLayout(false);
            this.menuStripMain.PerformLayout();
            this.toolStripContainer1.BottomToolStripPanel.ResumeLayout(false);
            this.toolStripContainer1.BottomToolStripPanel.PerformLayout();
            this.toolStripContainer1.ContentPanel.ResumeLayout(false);
            this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false);
            this.toolStripContainer1.TopToolStripPanel.PerformLayout();
            this.toolStripContainer1.ResumeLayout(false);
            this.toolStripContainer1.PerformLayout();
            this.statusStrip1.ResumeLayout(false);
            this.statusStrip1.PerformLayout();
            this.toolStripCommon.ResumeLayout(false);
            this.toolStripCommon.PerformLayout();
            this.contextMenuStripEdit.ResumeLayout(false);
            ((ISupportInitialize) this.treeGridViewTrace).EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void listAxesContext_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListView view = sender as ListView;
            if (view.SelectedItems.Count == 1)
            {
                ListViewItem item = view.SelectedItems[0];
                if (item.Tag != null)
                {
                    Coordinate tag = item.Tag as Coordinate;
                    string dimName = tag.Hierarchy.Name.Split(new char[] { '.' })[0].Replace("[", "").Replace("]", "");
                    StringBuilder builder = new StringBuilder();
                    builder.AppendFormat("({0}", tag.Member.UniqueName);
                    foreach (ListViewItem item2 in this.m_winCoordinates.ListWhere.Items)
                    {
                        Coordinate coordinate2 = item2.Tag as Coordinate;
                        string str2 = coordinate2.Hierarchy.Name.Split(new char[] { '.' })[0].Replace("[", "").Replace("]", "");
                        if (dimName.Equals(str2, StringComparison.InvariantCultureIgnoreCase))
                        {
                            builder.AppendFormat(",{0}", coordinate2.Member.UniqueName);
                        }
                    }
                    builder.Append(")");
                    this.ShowCoordinates(dimName, builder.ToString());
                }
            }
        }

        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (this.m_Connection.MetadataConnection != null)
            {
                this.m_Connection.MetadataConnection.Close();
            }
            if (this.m_Connection.QueryConnection != null)
            {
                this.m_Connection.QueryConnection.Close();
            }
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            this.Text = string.Format("MDX Studio v{0} Beta by Mosha Pasumansky", "0.4.14.0");
            this.dockPanel.BringToFront();
            this.m_Connection = new Connection();
            QueryWindow window = new QueryWindow();
            window.DockPanel = this.dockPanel;
            window.DockState = DockState.Document;
            window.MDXEditor.SelectionChanged += new EventHandler(this.editor_SelectionChanged);
            window.MDXEditor.ContextMenuStrip = this.contextMenuStripEdit;
            window.TabText = window.Text = string.Format("Query {0} - unnamed", ++this.m_iQueryWindow);
            window.m_Connection = this.m_Connection;
            window.Show();
            this.m_winMdxScript = new QueryWindow();
            this.m_winMdxScript.HideOnClose = true;
            this.m_winMdxScript.m_Connection = this.m_Connection;
            this.m_winMdxScript.MDXEditor.SelectionChanged += new EventHandler(this.editor_SelectionChanged);
            this.m_winMdxScript.MDXEditor.ReadOnly = true;
            this.m_winMdxScript.MDXEditor.ContextMenuStrip = this.contextMenuStripEdit;
            this.m_winMetadata = new MetadataWindow();
            this.m_winMetadata.DockPanel = this.dockPanel;
            this.m_winMetadata.DockTo(this.dockPanel, DockStyle.Left);
            this.m_winParseTree = new ParseWindow();
            this.m_winParseTree.DockPanel = this.dockPanel;
            this.m_winParseTree.DockTo(this.dockPanel, DockStyle.Left);
            this.m_winPerfmon = new PerfmonWindow();
            this.m_winPerfmon.DockPanel = this.dockPanel;
            this.m_winPerfmon.DockTo(this.dockPanel, DockStyle.Left);
            this.m_winResults = new ResultsWindow();
            this.m_winResults.Text = this.m_winResults.TabText = "Results";
            this.AxesContext = new MDXStudio.Context();
            this.GridQueryResults = new VirtualGrid(this.m_winResults.DataGridView, this.AxesContext);
            this.m_winResults.DataGridView.CellEnter += new DataGridViewCellEventHandler(this.dataGridCellSet_CellEnter);
            this.m_winResults.DataGridView.CellDoubleClick += new DataGridViewCellEventHandler(this.dataGridCellSet_CellDoubleClick);
            this.m_winResults.VirtualGrid = this.GridQueryResults;
            this.m_winResults.DockPanel = this.dockPanel;
            this.m_winResults.DockTo(this.dockPanel, DockStyle.Bottom);
            this.m_winDebugWatch = new ResultsWindow();
            this.m_winDebugWatch.Text = this.m_winDebugWatch.TabText = "Debug Watch";
            this.GridDebugWatch = new VirtualGrid(this.m_winDebugWatch.DataGridView, null);
            this.m_winDebugWatch.VirtualGrid = this.GridDebugWatch;
            this.m_winDebugWatch.DockPanel = this.dockPanel;
            this.m_winDebugWatch.DockTo(this.dockPanel, DockStyle.Bottom);
            this.m_DebugWatch = new DebugWatch();
            this.m_winDebugWatch.DebugWatch = this.m_DebugWatch;
            this.m_winMessages = new MessagesWindow();
            this.m_winMessages.DockPanel = this.dockPanel;
            this.m_winMessages.DockTo(this.dockPanel, DockStyle.Bottom);
            this.m_MessagesGrid = new MessageLog(this.m_winMessages.DataGridView, this.m_winMessages);
            this.m_winTrace = new TraceWindow();
            this.m_winDependencies = new DependenciesWindow();
            this.m_winCoordinates = new CoordinatesWindow();
            this.m_winCoordinates.DockPanel = this.dockPanel;
            this.m_winCoordinates.DockTo(this.dockPanel, DockStyle.Bottom);
            this.m_winCoordinates.ListAxes.SelectedIndexChanged += new EventHandler(this.listAxesContext_SelectedIndexChanged);
            this.m_winBrowser = new BrowserWindow();
            this.mSettings = new Settings();
            this.m_Connection.ServerName = this.mSettings.Connection_Server;
            UIUtil.AddBWClones(this.m_winMetadata.TreeViewMetadata.ImageList);
            this.AxesContext.m_ListView = this.m_winCoordinates.ListAxes;
            this.QueryContext = new MDXStudio.QueryContext();
            this.QueryContext.m_ListView = this.m_winCoordinates.ListWhere;
            this.PerfStats = new MDXStudio.PerfStats(this.m_winPerfmon.TextBox);
            this.m_TraceWatcher = new TraceWatcher();
            this.m_TraceWatcher.TreeGridView = this.m_winTrace.TreeGridViewTrace;
            this.m_MdxQuery = new Query(this.m_MessagesGrid, this.timerQuery, this.PerfStats, new ToolStripButton[] { this.toolStripButtonExecute, this.toolStripButtonDebug, this.toolStripButtonProfile });
            WigglyLinesPainter painter = new WigglyLinesPainter(window.MDXEditor);
            window.MDXEditor.Tag = painter;
            WigglyLinesPainter painter2 = new WigglyLinesPainter(this.m_winMdxScript.MDXEditor);
            this.m_winMdxScript.MDXEditor.Tag = painter2;
            if (this.m_Args.Length > 0)
            {
                string pFilePath = this.m_Args[0];
                window.MDXEditor.LoadFile(pFilePath, RichTextBoxStreamType.PlainText);
                window.Text = window.TabText = pFilePath;
                window.Changed = false;
                window.Show(this.dockPanel);
            }
            window.MDXEditor.Focus();
            this.DebugModeOff();
            this.Disconnect();
            this.Connect();
        }

        private void mdxScriptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.m_winMdxScript.Show(this.dockPanel);
        }

        private void messagesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.m_winMessages.Show(this.dockPanel);
        }

        private void metadataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.m_winMetadata.Show(this.dockPanel);
        }

        private void newQueryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            QueryWindow window = new QueryWindow();
            window.DockPanel = this.dockPanel;
            window.MDXEditor.SelectionChanged += new EventHandler(this.editor_SelectionChanged);
            window.MDXEditor.ContextMenuStrip = this.contextMenuStripEdit;
            window.TabText = window.Text = string.Format("Query {0} - unnamed", ++this.m_iQueryWindow);
            window.m_Connection = this.m_Connection;
            WigglyLinesPainter painter = new WigglyLinesPainter(window.MDXEditor);
            window.MDXEditor.Tag = painter;
            window.Show();
        }

        private void newToolStripButton_Click(object sender, EventArgs e)
        {
            this.newQueryToolStripMenuItem_Click(sender, e);
        }

        private void onlineEditionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.GotoDefaultWebBrowser("http://mdx.mosha.com");
        }

        private void openToolStripButton_Click(object sender, EventArgs e)
        {
            this.openToolStripMenuItem_Click(sender, e);
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
            if (currentMdxEditor != null)
            {
                QueryWindow activeDocument = this.dockPanel.ActiveDocument as QueryWindow;
                try
                {
                    OpenFileDialog dialog = new OpenFileDialog();
                    dialog.CheckFileExists = true;
                    dialog.CheckPathExists = true;
                    dialog.Filter = "MDX files (*.mdx)|*.mdx|All files (*.*)|*.*";
                    dialog.Multiselect = false;
                    dialog.Title = "Open MDX file";
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        currentMdxEditor.SuspendLayout();
                        this.Cursor = Cursors.WaitCursor;
                        string[] strArray = dialog.FileName.Split(new char[] { '\\' });
                        activeDocument.Tag = dialog.FileName;
                        activeDocument.Text = activeDocument.TabText = strArray[strArray.Length - 1];
                        this.saveToolStripMenuItem.Text = "&Save " + activeDocument.TabText;
                        this.saveAsToolStripMenuItem.Text = "&Save " + activeDocument.TabText + " As...";
                        currentMdxEditor.LoadFile(dialog.FileName, RichTextBoxStreamType.PlainText);
                        activeDocument.Changed = false;
                        activeDocument.Show(this.dockPanel);
                    }
                }
                catch (Exception exception)
                {
                    this.m_MessagesGrid.WriteErrorMessage(exception.Message);
                }
                finally
                {
                    currentMdxEditor.ResumeLayout();
                    this.Cursor = Cursors.Default;
                }
            }
        }

        private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new Options(this.m_formatOptions).ShowDialog();
        }

        private MDXParser.MDXParser Parse(string text, bool FillTree, bool IsExpression, bool TryAnother)
        {
            MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
            if (currentMdxEditor == null)
            {
                return null;
            }
            string mdx = text;
            if (mdx == null)
            {
                if (currentMdxEditor.SelectionLength > 0)
                {
                    mdx = currentMdxEditor.SelectedText;
                }
                else
                {
                    mdx = currentMdxEditor.Text;
                }
            }
            Locator l = new Locator();
            if (currentMdxEditor.SelectionLength > 0)
            {
                l.Position = currentMdxEditor.SelectionStart;
            }
            MDXParser.CubeInfo cb = null;
            if ((this.m_Connection.MetadataConnection != null) && (this.toolStripComboBoxCubes.SelectedIndex >= 0))
            {
                string name = ((MdCube) this.toolStripComboBoxCubes.Items[this.toolStripComboBoxCubes.SelectedIndex]).Name;
                if (!string.IsNullOrEmpty(name))
                {
                    AdomdClientCubeInfo info2 = new AdomdClientCubeInfo(name, this.m_Connection.MetadataConnection);
                    cb = info2;
                }
            }
            if (cb == null)
            {
                cb = new MDXParser.CubeInfo();
            }
            TextBoxSource src = new TextBoxSource(currentMdxEditor, l);
            MDXParser.MDXParser parser = new MDXParser.MDXParser(mdx, src, cb);
            int selectionStart = currentMdxEditor.SelectionStart;
            currentMdxEditor.SelectAll();
            currentMdxEditor.SelectionBackColor = SystemColors.Window;
            currentMdxEditor.SelectionStart = selectionStart;
            currentMdxEditor.SelectionLength = 0;
            currentMdxEditor.Focus();
            int num2 = currentMdxEditor.SelectionStart;
            try
            {
                if (IsExpression)
                {
                    parser.ParseExpression();
                }
                else
                {
                    parser.Parse();
                }
            }
            catch (MDXParserException exception)
            {
                if (TryAnother)
                {
                    try
                    {
                        if (IsExpression)
                        {
                            parser.Parse();
                        }
                        else
                        {
                            parser.ParseExpression();
                        }
                        goto Label_016E;
                    }
                    catch (Exception)
                    {
                        this.m_MessagesGrid.Populate(exception.Messages);
                        return null;
                    }
                }
                this.m_MessagesGrid.Populate(exception.Messages);
            }
            finally
            {
                currentMdxEditor.SelectionStart = num2;
                currentMdxEditor.SelectionLength = 0;
            }
        Label_016E:
            if (FillTree)
            {
                System.Windows.Forms.TreeNode parseTreeNode = this.GetParseTreeNode(currentMdxEditor.ReadOnly ? "MDX Script" : "Queries");
                parseTreeNode.Nodes.Clear();
                parseTreeNode.Tag = parser.GetNode();
                parser.FillTree(parseTreeNode);
                parseTreeNode.Expand();
                parseTreeNode.TreeView.SelectedNode = parseTreeNode;
            }
            return parser;
        }

        private void ParseCellPermission(System.Windows.Forms.TreeNode CellPermNode, CellPermission cp)
        {
            try
            {
                MDXParser.MDXParser parser = new MDXParser.MDXParser(cp.get_Expression());
                parser.ParseExpression();
                System.Windows.Forms.TreeNode parentnode = CellPermNode.Nodes.Add(cp.get_Access().ToString());
                parentnode.ImageKey = parentnode.SelectedImageKey = "MeasureCalculated.ico";
                parser.FillTree(parentnode);
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(string.Format("Parsing error in cell permission for role {0}: {2}", cp.get_Parent().get_Name(), exception.Message));
            }
        }

        private void ParseClick(bool IsExpression)
        {
            try
            {
                this.ClearMessages();
                MDXParser.MDXParser parser = this.Parse(null, true, IsExpression, true);
                if (parser != null)
                {
                    IDockContent activeDocument = this.dockPanel.ActiveDocument;
                    this.m_winDependencies.Show(this.dockPanel);
                    this.m_winParseTree.Show(this.dockPanel);
                    activeDocument.DockHandler.Show(this.dockPanel);
                    MDXNode node = parser.GetNode();
                    DependencyGraph g = new DependencyGraph();
                    node.BuildDependencyGraph(g, null);
                    this.m_winDependencies.DataGridView.Rows.Clear();
                    g.UpdateStats(this.m_winDependencies.DataGridView);
                    g.Visualize(this.m_winDependencies.NetMapControl, null, null);
                    MDXSelectNode select = parser.GetSelect();
                    if ((select != null) && ((this.m_Connection.QueryConnection != null) && (this.toolStripComboBoxCubes.SelectedIndex >= 0)))
                    {
                        string name = ((MdCube) this.toolStripComboBoxCubes.Items[this.toolStripComboBoxCubes.SelectedIndex]).Name;
                        this.QueryContext.SetSelect(select, this.m_Connection.QueryConnection, name);
                    }
                }
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
        }

        private void ParseDimPermission(System.Windows.Forms.TreeNode DimPermNode, AttributePermission dp)
        {
            try
            {
                System.Windows.Forms.TreeNode node = DimPermNode.Nodes.Add(dp.get_Attribute().get_Name());
                node.ImageKey = node.SelectedImageKey = "Dimension.ico";
                if (!string.IsNullOrEmpty(dp.get_AllowedSet()))
                {
                    System.Windows.Forms.TreeNode parentnode = node.Nodes.Add("Allowed Set");
                    MDXParser.MDXParser parser = new MDXParser.MDXParser(dp.get_AllowedSet());
                    parser.ParseExpression();
                    parser.FillTree(parentnode);
                }
                if (!string.IsNullOrEmpty(dp.get_DeniedSet()))
                {
                    System.Windows.Forms.TreeNode node3 = node.Nodes.Add("Denied Set");
                    MDXParser.MDXParser parser2 = new MDXParser.MDXParser(dp.get_DeniedSet());
                    parser2.ParseExpression();
                    parser2.FillTree(node3);
                }
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(string.Format("Parsing error in dimension permission for role: {2}", exception.Message));
            }
        }

        private void parseExpressionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.ParseClick(true);
        }

        private void ParseKpiProperty(System.Windows.Forms.TreeNode KpiNode, string kpiname, string kpiprop, string propname)
        {
            if (kpiprop != null)
            {
                try
                {
                    MDXParser.MDXParser parser = new MDXParser.MDXParser(kpiprop);
                    parser.ParseExpression();
                    System.Windows.Forms.TreeNode parentnode = KpiNode.Nodes.Add(propname);
                    parentnode.ImageKey = parentnode.SelectedImageKey = "MeasureCalculated.ico";
                    parser.FillTree(parentnode);
                }
                catch (Exception exception)
                {
                    this.m_MessagesGrid.WriteErrorMessage(string.Format("Parsing error in {0}.{1}: {2}", kpiname, propname, exception.Message));
                }
            }
        }

        private void parseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.toolStripButtonParse_Click(null, null);
        }

        private void parseTreeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.m_winParseTree.Show(this.dockPanel);
        }

        private void pasteContextMenuItem_Click(object sender, EventArgs e)
        {
            this.ProcessPaste();
        }

        private void pasteToolStripButton_Click(object sender, EventArgs e)
        {
            this.ProcessPaste();
        }

        private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.ProcessPaste();
        }

        private void perfmonCountersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.m_winPerfmon.Show(this.dockPanel);
        }

        private void ProcessCopy()
        {
            MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
            if (currentMdxEditor != null)
            {
                if (!string.IsNullOrEmpty(currentMdxEditor.SelectedText))
                {
                    Clipboard.SetText(currentMdxEditor.SelectedText);
                }
            }
            else if ((this.dockPanel.ActiveDocument == null) || (this.dockPanel.ActiveDocument.GetType() != typeof(DependenciesWindow)))
            {
                Bitmap bitmap = new Bitmap(this.m_winDependencies.NetMapControl.Width, this.m_winDependencies.NetMapControl.Height);
                this.m_winDependencies.NetMapControl.DrawToBitmap(bitmap, this.m_winDependencies.NetMapControl.Bounds);
                Clipboard.SetImage(bitmap);
            }
        }

        private void ProcessCut()
        {
            MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
            if ((currentMdxEditor != null) && !currentMdxEditor.ReadOnly)
            {
                if (!string.IsNullOrEmpty(currentMdxEditor.SelectedText))
                {
                    Clipboard.SetText(currentMdxEditor.SelectedText);
                }
                currentMdxEditor.SelectedText = "";
            }
        }

        private void ProcessPaste()
        {
            MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
            if ((currentMdxEditor != null) && !string.IsNullOrEmpty(Clipboard.GetText()))
            {
                currentMdxEditor.SelectedText = Clipboard.GetText();
            }
        }

        private void profilerTraceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.m_winTrace.Show(this.dockPanel);
        }

        private void questionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                this.GotoDefaultWebBrowser("http://www.ssas-info.com/forum/search.php?search_id=egosearch");
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
        }

        private void redoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
            if (currentMdxEditor != null)
            {
                currentMdxEditor.Redo();
            }
        }

        private void replaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
            if (currentMdxEditor != null)
            {
                currentMdxEditor.NewSearch(true);
            }
        }

        private void resultsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.m_winResults.Show(this.dockPanel);
        }

        internal void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            QueryWindow currentQueryWindow = this.GetCurrentQueryWindow();
            if (currentQueryWindow != null)
            {
                try
                {
                    SaveFileDialog dialog = new SaveFileDialog();
                    dialog.CheckFileExists = false;
                    dialog.CheckPathExists = true;
                    dialog.OverwritePrompt = true;
                    dialog.Filter = "MDX files (*.mdx)|*.mdx|All files (*.*)|*.*";
                    dialog.Title = "Save File As";
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        this.Cursor = Cursors.WaitCursor;
                        currentQueryWindow.MDXEditor.SaveFile(dialog.FileName, RichTextBoxStreamType.PlainText);
                        string[] strArray = dialog.FileName.Split(new char[] { '\\' });
                        currentQueryWindow.Tag = dialog.FileName;
                        currentQueryWindow.Text = currentQueryWindow.TabText = strArray[strArray.Length - 1];
                        this.saveToolStripMenuItem.Text = "&Save " + currentQueryWindow.Text + "  Ctrl+S";
                        this.saveAsToolStripMenuItem.Text = "&Save " + currentQueryWindow.Text + " As...";
                    }
                }
                catch (Exception exception)
                {
                    this.m_MessagesGrid.WriteErrorMessage(exception.Message);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }

        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            this.saveToolStripMenuItem_Click(sender, e);
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            QueryWindow currentQueryWindow = this.GetCurrentQueryWindow();
            if (currentQueryWindow != null)
            {
                try
                {
                    if (currentQueryWindow.Tag == null)
                    {
                        this.saveAsToolStripMenuItem_Click(sender, e);
                    }
                    else
                    {
                        this.Cursor = Cursors.WaitCursor;
                        currentQueryWindow.MDXEditor.SaveFile(currentQueryWindow.Tag.ToString(), RichTextBoxStreamType.PlainText);
                        currentQueryWindow.Changed = false;
                    }
                }
                catch (Exception exception)
                {
                    this.m_MessagesGrid.WriteErrorMessage(exception.Message);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }

        private void searchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.GotoDefaultWebBrowser("http://search.live.com");
        }

        private void SessionTrace_OnEvent(object sender, TraceEventArgs e)
        {
            switch (e.get_EventClass())
            {
                case 6:
                {
                    TraceEventSubclass subclass = e.get_EventSubclass();
                    if (subclass == 0x15)
                    {
                        this.m_TraceWatcher.OnPartitionQuery(e);
                        return;
                    }
                    if (subclass == 0x1c)
                    {
                        break;
                    }
                    return;
                }
                case 7:
                case 8:
                case 11:
                case 60:
                case 0x49:
                    break;

                case 9:
                    this.m_TraceWatcher.OnQueryBegin(e);
                    return;

                case 10:
                    this.m_TraceWatcher.OnQueryEnd(e);
                    return;

                case 12:
                    this.m_TraceWatcher.OnQuerySubcubeExEnd(e);
                    return;

                case 0x48:
                    this.m_TraceWatcher.OnNonEmptyBegin(e);
                    return;

                case 0x4a:
                    this.m_TraceWatcher.OnNonEmptyEnd(e);
                    return;

                case 0x4b:
                    this.m_TraceWatcher.OnSerializeBegin(e);
                    return;

                case 0x4c:
                    switch (e.get_EventSubclass())
                    {
                    }
                    break;

                case 0x4d:
                    this.m_TraceWatcher.OnSerializeEnd(e);
                    return;

                default:
                    return;
            }
        }

        private void showCoordinateOverwritesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.toolStripButtonCoord_Click(null, null);
        }

        private void ShowCoordinates(string dimName, string memberName)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat("SELECT {{}} ON 1, Generate({{({0})}}, {{(", memberName);
            bool flag = true;
            CubeDef def = this.m_Connection.MetadataConnection.Cubes[this.toolStripComboBoxCubes.Text];
            Dimension dimension = def.Dimensions[dimName];
            HierarchyCollection.Enumerator enumerator = dimension.AttributeHierarchies.GetEnumerator();
            while (enumerator.MoveNext())
            {
                Hierarchy current = enumerator.Current;
                if (!flag)
                {
                    builder.Append(", ");
                }
                flag = false;
                builder.Append(current.UniqueName);
            }
            builder.AppendFormat(")}}) ON 0 FROM [{0}]", this.toolStripComboBoxCubes.Text);
            CellSet csResult = new AdomdCommand(builder.ToString(), this.m_Connection.QueryConnection).ExecuteCellSet();
            this.m_winDebugWatch.Show(this.dockPanel);
            this.m_winDebugWatch.DataGridView.ColumnHeadersVisible = false;
            this.GridDebugWatch.DrawCellSetInGrid(csResult, this.m_MessagesGrid, true);
        }

        private void startDebuggingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.DebugModeOn();
        }

        private void stopDebuggingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.DebugModeOff();
        }

        private void tabControlResults_SelectedIndexChanged(object sender, EventArgs e)
        {
        }

        private void timerQuery_Tick(object sender, EventArgs e)
        {
            Timer timer = sender as Timer;
            TimeSpan span = TimeSpan.Parse(this.toolStripStatusLabelTimer.Text).Add(new TimeSpan(0, 0, 0, 0, timer.Interval));
            this.toolStripStatusLabelTimer.Text = string.Format("{0}:{1}:{2}.{3}", new object[] { span.Hours, span.Minutes, span.Seconds, span.Milliseconds / 100 });
        }

        private void toolStripButtonAnalyze_Click(object sender, EventArgs e)
        {
            MDXParser.MDXParser parser = this.Parse(null, false, false, true);
            if (parser != null)
            {
                this.ClearMessages();
                Analyzer analyzer = parser.Analyze();
                if (analyzer.Messages.Count > 0)
                {
                    this.m_MessagesGrid.Populate(analyzer.Messages);
                }
                else
                {
                    this.m_MessagesGrid.WriteMessage("No issues with MDX were found");
                }
                this.m_winMessages.Show(this.dockPanel);
            }
        }

        private void toolStripButtonConnect_Click(object sender, EventArgs e)
        {
            this.Connect();
        }

        private void toolStripButtonCoord_Click(object sender, EventArgs e)
        {
            try
            {
                string selectedText;
                string text;
                MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
                if (currentMdxEditor.SelectedText.Length > 0)
                {
                    selectedText = currentMdxEditor.SelectedText;
                }
                else
                {
                    selectedText = currentMdxEditor.Text;
                }
                if ((this.m_winMetadata.TreeViewMetadata.SelectedNode != null) && (this.m_winMetadata.TreeViewMetadata.SelectedNode.ImageKey == "Dimension.ico"))
                {
                    text = this.m_winMetadata.TreeViewMetadata.SelectedNode.Text;
                }
                else
                {
                    Match match = new Regex(@"(?<dim>[^.(]+)[\.](?<other>.+)").Match(selectedText);
                    if (!match.Success)
                    {
                        throw new SystemException("Please select dimension in the metadata pane");
                    }
                    text = match.Groups["dim"].Value.Replace("[", "").Replace("]", "");
                }
                this.ShowCoordinates(text, selectedText);
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }

        private void toolStripButtonDebug_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.toolStripComboBoxCubes.SelectedIndex < 0)
                {
                    this.m_MessagesGrid.Clear();
                    throw new Exception("Please select the cube first");
                }
                string name = ((MdCube) this.toolStripComboBoxCubes.Items[this.toolStripComboBoxCubes.SelectedIndex]).Name;
                this.DebugModeOn();
                MDXParser.MDXParser parser = this.Parse(null, true, false, false);
                if (parser != null)
                {
                    this.AxesContext.Clear();
                    this.QueryContext.Clear();
                    this.ClearResults();
                    this.ClearDebugWatch();
                    this.ClearMessages();
                    this.m_winCoordinates.Show(this.dockPanel);
                    this.m_winResults.Show(this.dockPanel);
                    this.GetParseTreeNode("Queries").ExpandAll();
                    MDXSelectNode select = parser.GetSelect();
                    if (select != null)
                    {
                        this.QueryContext.SetSelect(select, this.m_Connection.QueryConnection, name);
                        this.m_winCoordinates.ListWhere.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                        string mdxText = parser.GetMdxText();
                        this.PerfStats.Clear();
                        this.m_MdxQuery.RunAndDisplay(this.m_Connection.QueryConnection, this.m_Connection.AMOConnection, this.m_Connection.ServerName, mdxText, select.Params, this.GridQueryResults, this.m_winResults);
                    }
                }
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
        }

        internal void toolStripButtonExecute_Click(object sender, EventArgs e)
        {
            try
            {
                this.m_winPerfmon.Show(this.dockPanel);
                this.m_winResults.Show(this.dockPanel);
                this.AxesContext.Clear();
                this.QueryContext.Clear();
                this.ClearResults();
                this.ClearDebugWatch();
                this.ClearMessages();
                this.Cursor = Cursors.WaitCursor;
                DateTime now = DateTime.Now;
                MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
                string mdx = null;
                if (currentMdxEditor.SelectedText.Length > 0)
                {
                    mdx = currentMdxEditor.SelectedText;
                }
                else
                {
                    mdx = currentMdxEditor.Text;
                }
                MDXParamParser parser = new MDXParamParser();
                mdx = parser.ParseParameters(mdx);
                this.DebugModeOff();
                this.PerfStats.Clear();
                this.toolStripStatusLabelTimer.Text = "0:0:0.0";
                this.m_MdxQuery.RunAndDisplay(this.m_Connection.QueryConnection, this.m_Connection.AMOConnection, this.m_Connection.ServerName, mdx, parser.m_Params, this.GridQueryResults, this.m_winResults);
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }

        private void toolStripButtonFormat_Click(object sender, EventArgs e)
        {
            this.FormatClick(false);
        }

        internal void toolStripButtonParse_Click(object sender, EventArgs e)
        {
            this.ParseClick(false);
        }

        private void toolStripButtonProfile_Click(object sender, EventArgs e)
        {
            try
            {
                MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
                if (currentMdxEditor != null)
                {
                    this.m_winPerfmon.Show(this.dockPanel);
                    this.m_winTrace.Show(this.dockPanel);
                    this.DebugModeOff();
                    this.m_MessagesGrid.Clear();
                    if (this.toolStripComboBoxCubes.SelectedIndex >= 0)
                    {
                        string name = ((MdCube) this.toolStripComboBoxCubes.Items[this.toolStripComboBoxCubes.SelectedIndex]).Name;
                        if (!string.IsNullOrEmpty(name))
                        {
                            this.m_winTrace.TreeGridViewTrace.Nodes.Clear();
                            this.ClearCache();
                            this.m_MessagesGrid.WriteMessage("Execute MDX Script");
                            string queryText = string.Format("SELECT {0} ON COLUMNS FROM [{1}]", "{}", name);
                            this.m_TraceWatcher.AddWatchQuery("Execute MDX Script");
                            this.m_MdxQuery.WaitForCompletion();
                            this.PerfStats.Clear();
                            this.m_MdxQuery.RunAndDisplay(this.m_Connection.QueryConnection, this.m_Connection.AMOConnection, this.m_Connection.ServerName, queryText, null, null, null);
                            this.m_MessagesGrid.WriteMessage("Execute query on cold caches");
                            queryText = null;
                            if (currentMdxEditor.SelectedText.Length > 0)
                            {
                                queryText = currentMdxEditor.SelectedText;
                            }
                            else
                            {
                                queryText = currentMdxEditor.Text;
                            }
                            MDXParamParser parser = new MDXParamParser();
                            queryText = parser.ParseParameters(queryText);
                            this.m_MdxQuery.WaitForCompletion();
                            this.PerfStats.Clear();
                            this.PerfStats.DisplayTitle("Cold cache execution");
                            this.PerfStats.DisplayTitle("");
                            this.m_TraceWatcher.AddWatchQuery("Cold cache execution");
                            this.m_MdxQuery.RunAndDisplay(this.m_Connection.QueryConnection, this.m_Connection.AMOConnection, this.m_Connection.ServerName, queryText, parser.m_Params, null, null);
                            this.m_MessagesGrid.WriteMessage("Execute query on warm caches");
                            this.m_MdxQuery.WaitForCompletion();
                            long duration = this.PerfStats.Duration;
                            this.PerfStats.DisplayTitle("");
                            this.PerfStats.DisplayTitle("Warm cache execution");
                            this.PerfStats.DisplayTitle("");
                            this.m_TraceWatcher.AddWatchQuery("Warm cache execution");
                            this.m_MdxQuery.RunAndDisplay(this.m_Connection.QueryConnection, this.m_Connection.AMOConnection, this.m_Connection.ServerName, queryText, parser.m_Params, null, null);
                            this.m_MdxQuery.WaitForCompletion();
                            float num3 = ((float) this.PerfStats.Duration) / ((float) duration);
                            if (num3 > 1f)
                            {
                                num3 = 1f;
                            }
                            float num4 = 1f - num3;
                            this.PerfStats.DisplayTitle("");
                            this.PerfStats.DisplaySomeData("Percent cold caches", num4.ToString("P"));
                            this.PerfStats.DisplaySomeData("Percent warm caches", num3.ToString("P"));
                        }
                    }
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }

        private void toolStripButtonReconnect_Click(object sender, EventArgs e)
        {
            this.Disconnect();
            this.Connect();
        }

        private void toolStripButtonStop_Click(object sender, EventArgs e)
        {
            try
            {
                this.m_MdxQuery.Cancel();
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
        }

        private void toolStripComboBoxCatalogs_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.m_winMetadata.TreeViewMetadata.Nodes.Clear();
            string database = this.toolStripComboBoxCatalogs.Items[this.toolStripComboBoxCatalogs.SelectedIndex].ToString();
            this.toolStripComboBoxCubes.Items.Clear();
            try
            {
                this.m_Connection.MetadataConnection.ChangeDatabase(database);
                this.m_Connection.QueryConnection.ChangeDatabase(database);
                this.m_Connection.CurrentCatalog = database;
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
            AdomdRestrictionCollection restrictions = new AdomdRestrictionCollection();
            restrictions.Add(new AdomdRestriction("CATALOG_NAME", database));
            if (this.mSettings.Metadata_ShowDimensionCubes)
            {
                restrictions.Add("CUBE_SOURCE", 0);
            }
            this.FillList(this.toolStripComboBoxCubes.Items, "MDSCHEMA_CUBES", restrictions, "CUBE_NAME");
        }

        private void toolStripComboBoxCubes_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                this.m_winDependencies.Hide();
                this.m_winDependencies.DataGridView.Rows.Clear();
                this.m_winMdxScript.Hide();
                this.m_winMdxScript.MDXEditor.Text = "";
                this.GetParseTreeNode("MDX Script").Remove();
                this.GetParseTreeNode("KPIs").Remove();
                this.GetParseTreeNode("Actions").Remove();
                this.GetParseTreeNode("Security").Remove();
                if (this.toolStripComboBoxCubes.SelectedIndex != -1)
                {
                    this.Cursor = Cursors.WaitCursor;
                    this.m_winMetadata.TreeViewMetadata.SuspendLayout();
                    this.m_winMetadata.TreeViewMetadata.Nodes.Clear();
                    string str = this.toolStripComboBoxCatalogs.Items[this.toolStripComboBoxCatalogs.SelectedIndex].ToString();
                    string name = ((MdCube) this.toolStripComboBoxCubes.Items[this.toolStripComboBoxCubes.SelectedIndex]).Name;
                    this.m_winMetadata.TreeBuilder.RebuidTree(this.m_winMetadata.TreeViewMetadata, name);
                    this.m_winMetadata.TreeViewMetadata.ResumeLayout();
                    this.m_Connection.CurrentCatalog = str;
                    this.m_Connection.CurrentCube = name;
                    if (this.m_Connection.QueryConnection != null)
                    {
                        string str3 = string.Format("{0};Initial Catalog={1};Cube={2}", this.m_ConnectionString, str, name);
                        this.m_Connection.QueryConnection.Close();
                        this.m_Connection.QueryConnection.ConnectionString = str3;
                        this.m_Connection.QueryConnection.Open();
                        try
                        {
                            if (this.m_Connection.TraceConnection.get_SessionTrace().get_IsStarted())
                            {
                                this.m_Connection.TraceConnection.get_SessionTrace().Stop();
                            }
                            this.m_Connection.TraceConnection.Disconnect();
                            this.m_Connection.TraceConnection.Connect(this.m_Connection.QueryConnection.ConnectionString, this.m_Connection.QueryConnection.SessionID);
                            this.m_Connection.TraceConnection.get_SessionTrace().add_OnEvent(new TraceEventHandler(this, (IntPtr) this.SessionTrace_OnEvent));
                            this.m_Connection.TraceConnection.get_SessionTrace().Start();
                        }
                        catch (Exception)
                        {
                            this.m_Connection.TraceConnection = null;
                        }
                    }
                    if (this.m_Connection.AMOConnection != null)
                    {
                        Cube cube = this.m_Connection.AMOConnection.get_Databases().FindByName(str).get_Cubes().FindByName(name);
                        if (cube != null)
                        {
                            MdxScript script = cube.get_DefaultMdxScript();
                            this.m_winMdxScript.MDXEditor.Clear();
                            if (script != null)
                            {
                                this.m_winMdxScript.Show(this.dockPanel);
                                this.m_winMdxScript.MDXEditor.AppendText(script.get_Commands().get_Item(0).get_Text());
                                this.m_winMdxScript.MDXEditor.SelectionStart = 0;
                                this.m_winMdxScript.MDXEditor.SelectionLength = 0;
                                this.m_winMdxScript.MDXEditor.Focus();
                                this.m_winMdxScript.TabText = this.m_winMdxScript.Text = cube.get_Name() + " - MDX Script";
                                this.toolStripButtonParse_Click(null, null);
                            }
                            KpiCollection kpis = cube.get_Kpis();
                            if (kpis.get_Count() > 0)
                            {
                                System.Windows.Forms.TreeNode node2 = this.GetParseTreeNode("KPIs");
                                node2.ImageKey = node2.SelectedImageKey = "Kpi.ico";
                                node2.Nodes.Clear();
                                foreach (Kpi kpi in kpis)
                                {
                                    System.Windows.Forms.TreeNode kpiNode = node2.Nodes.Add(kpi.get_Name());
                                    kpiNode.ImageKey = kpiNode.SelectedImageKey = "Kpi.ico";
                                    this.ParseKpiProperty(kpiNode, kpi.get_Name(), kpi.get_Value(), "Value");
                                    this.ParseKpiProperty(kpiNode, kpi.get_Name(), kpi.get_Goal(), "Goal");
                                    this.ParseKpiProperty(kpiNode, kpi.get_Name(), kpi.get_Status(), "Status");
                                    this.ParseKpiProperty(kpiNode, kpi.get_Name(), kpi.get_Trend(), "Trend");
                                }
                                node2.Expand();
                            }
                            ActionCollection actions = cube.get_Actions();
                            if (actions.get_Count() > 0)
                            {
                                System.Windows.Forms.TreeNode node4 = this.GetParseTreeNode("Actions");
                                node4.ImageKey = node4.SelectedImageKey = "FolderClosed.ico";
                                node4.Nodes.Clear();
                                foreach (Action action in actions)
                                {
                                    System.Windows.Forms.TreeNode node5 = node4.Nodes.Add(action.get_Name());
                                    node5.ImageKey = node5.SelectedImageKey = "FolderClosed.ico";
                                    if (action.get_CaptionIsMdx())
                                    {
                                        this.ParseKpiProperty(node5, action.get_Name(), action.get_Caption(), "Caption");
                                    }
                                }
                                node4.Expand();
                            }
                            CubePermissionCollection permissions = cube.get_CubePermissions();
                            if (permissions.get_Count() > 0)
                            {
                                System.Windows.Forms.TreeNode node6 = this.GetParseTreeNode("Security");
                                node6.ImageKey = node6.SelectedImageKey = "FolderClosed.ico";
                                node6.Nodes.Clear();
                                foreach (CubePermission permission in permissions)
                                {
                                    System.Windows.Forms.TreeNode node7 = node6.Nodes.Add(permission.get_Role().get_Name());
                                    node7.ImageKey = node7.SelectedImageKey = "FolderClosed.ico";
                                    if (permission.get_CellPermissions().get_Count() > 0)
                                    {
                                        System.Windows.Forms.TreeNode cellPermNode = node7.Nodes.Add("Cell Permissions");
                                        cellPermNode.ImageKey = cellPermNode.SelectedImageKey = "FolderClosed.ico";
                                        foreach (CellPermission permission2 in permission.get_CellPermissions())
                                        {
                                            this.ParseCellPermission(cellPermNode, permission2);
                                        }
                                    }
                                    if (permission.get_DimensionPermissions().get_Count() > 0)
                                    {
                                        System.Windows.Forms.TreeNode dimPermNode = node7.Nodes.Add("Dimension Permissions");
                                        dimPermNode.ImageKey = dimPermNode.SelectedImageKey = "FolderClosed.ico";
                                        foreach (CubeDimensionPermission permission3 in permission.get_DimensionPermissions())
                                        {
                                            foreach (AttributePermission permission4 in permission3.get_AttributePermissions())
                                            {
                                                this.ParseDimPermission(dimPermNode, permission4);
                                            }
                                        }
                                    }
                                    node7.Expand();
                                }
                                node6.Expand();
                            }
                            System.Windows.Forms.TreeNode parseTreeNode = this.GetParseTreeNode("MDX Script");
                            this.m_winParseTree.ParseTreeView.SelectedNode = parseTreeNode;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }

        private void traceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.mTraceDlg = new TracerDlg();
            Server pServer = new Server();
            pServer.Connect(this.m_Connection.QueryConnection.ConnectionString, this.m_Connection.QueryConnection.SessionID);
            this.mTraceDlg.Tracer.OnConnect(pServer);
            this.mTraceDlg.DockPanel = this.dockPanel;
            this.mTraceDlg.DockTo(this.dockPanel, DockStyle.Bottom);
            this.mTraceDlg.Show(this.dockPanel);
        }

        private void uncommentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
            if (currentMdxEditor != null)
            {
                int lineFromCharIndex = currentMdxEditor.GetLineFromCharIndex(currentMdxEditor.SelectionStart);
                int num2 = currentMdxEditor.GetLineFromCharIndex(currentMdxEditor.SelectionStart + currentMdxEditor.SelectionLength);
                currentMdxEditor.SelectionLength = 0;
                for (int i = lineFromCharIndex; i <= num2; i++)
                {
                    int firstCharIndexFromLine = currentMdxEditor.GetFirstCharIndexFromLine(i);
                    if ((firstCharIndexFromLine + 2) >= currentMdxEditor.TextLength)
                    {
                        return;
                    }
                    if ((currentMdxEditor.Text[firstCharIndexFromLine] == '/') && (currentMdxEditor.Text[firstCharIndexFromLine + 1] == '/'))
                    {
                        currentMdxEditor.SelectionStart = firstCharIndexFromLine;
                        currentMdxEditor.SelectionLength = 2;
                        currentMdxEditor.SelectedText = "";
                        currentMdxEditor.SelectionLength = 0;
                    }
                }
            }
        }

        private void undoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MdxEditor currentMdxEditor = this.GetCurrentMdxEditor();
            if (currentMdxEditor != null)
            {
                currentMdxEditor.Undo();
            }
        }

        internal void UpdateDebugWatch()
        {
            if ((this.m_Connection.QueryConnection != null) && (this.m_Connection.QueryConnection.State == ConnectionState.Open))
            {
                System.Windows.Forms.TreeNode selectedNode = this.m_winParseTree.ParseTreeView.SelectedNode;
                if (selectedNode != null)
                {
                    this.UpdateDebugWatch(selectedNode, false);
                }
            }
        }

        internal void UpdateDebugWatch(System.Windows.Forms.TreeNode treeNode, bool watchObject)
        {
            try
            {
                if ((this.m_DebugWatch != null) && this.m_fDebugMode)
                {
                    string name = ((MdCube) this.toolStripComboBoxCubes.Items[this.toolStripComboBoxCubes.SelectedIndex]).Name;
                    if (treeNode.Tag != null)
                    {
                        MDXExpNode expNode = ((MDXNode) treeNode.Tag).GetExpNode();
                        if (expNode == null)
                        {
                            this.ClearDebugWatch();
                        }
                        else
                        {
                            CodeGenerator generator = new CodeGenerator();
                            string calcMemberParentName = generator.GetCalcMemberParentName(treeNode);
                            if (calcMemberParentName == null)
                            {
                                calcMemberParentName = "[Measures]";
                            }
                            string calcMemberName = generator.GetCalcMemberName(treeNode);
                            if (calcMemberName == null)
                            {
                                calcMemberName = string.Format("[{0}]", expNode.GetLabel());
                            }
                            else if (calcMemberName.StartsWith("["))
                            {
                                calcMemberName = "[*" + calcMemberName.Substring(1);
                            }
                            else
                            {
                                calcMemberName = "[*" + calcMemberName + "]";
                            }
                            calcMemberName = expNode.GetLabel().Replace('[', ' ').Replace(']', ' ');
                            this.m_DebugWatch.Update(expNode, calcMemberParentName, calcMemberName, watchObject);
                            AdomdCommand command = new AdomdCommand(this.m_DebugWatch.BuildMDX(this.QueryContext.m_Select, name), this.m_Connection.QueryConnection);
                            if ((this.QueryContext.m_Select != null) && (this.QueryContext.m_Select.Params != null))
                            {
                                foreach (MDXParameter parameter in this.QueryContext.m_Select.Params)
                                {
                                    command.Parameters.Add(parameter.Name, parameter.Value);
                                }
                            }
                            CellSet csResult = command.ExecuteCellSet();
                            this.m_winDebugWatch.Show(this.dockPanel);
                            this.m_winDebugWatch.DataGridView.ColumnHeadersVisible = true;
                            this.GridDebugWatch.DrawCellSetInGrid(csResult, this.m_MessagesGrid, false);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                this.m_MessagesGrid.WriteErrorMessage(exception.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
    }
}

